A slight variation on the implementation which makes it great for single-page apps that need local events.
Instead of attaching it to the body (global events), you can also attach to the current 'page' element. Now all your events can subscribe to the local event handler. There's an added bonus that when the page is removed, the event handlers are automatically destroyed, too.
4 comments
[ 5.1 ms ] story [ 20.1 ms ] threadhttps://github.com/mroderick/PubSubJS
Instead of attaching it to the body (global events), you can also attach to the current 'page' element. Now all your events can subscribe to the local event handler. There's an added bonus that when the page is removed, the event handlers are automatically destroyed, too.