Decouple your code using a cross-platform publish/subscribe mechanism