Publish / Subscribe Events in JavaScript

Some situations may require developers to call multiple methods on occurrence of an event. When we do know what all methods needs to be called before hand, then we could hard code ‘the set of methods’ that needs to be called. However, what if we do not know ‘the set of methods’ upfront?

In C# we may accomplish this using Multi-cast Delegate, Observer Pattern, a subset of Publish/Subscribe Pattern. So, how are we going to deal with this issue in JavaScript? Continue reading