Maybe someone knows more approaches to communicate between components?
I don’t get the difference between ‘Publish/Subscribe’ and ‘Custom Events’ in the article. To me it just looks like slightly different syntax for the same thing. What am I missing?
Just found good explanation in difference between dispatcher and pub-sub
This is different from generic pub-sub systems in two ways:
Callbacks are not subscribed to particular events. Every payload is dispatched to every registered callback.
Callbacks can be deferred in whole or part until other callbacks have been executed.
The difference is, with Custom Events you are working with Document object and each event is attached to Document, so if you have thousands it may cause some performance. In Publish/Subscribe approach you are working with Object and it is easier to unsubscribe all in one place.
Basically, both approaches are same.