The comparison below is just about the basic features of subscribing to an event type, dispatching and removing an event listener. It isn't based on available features but on differences between basic implementations of each concept and pros and cons of using each one. Some things listed as cons can be avoided by "smart implementations" and "hacks" but are usually present on most cases.
All the implementations accomplish the same task and are based on the same design pattern (Observer), they also have many things in common but do things in a slightly different way. This page is intended to help you choose which one fits better your work flow and the kind of problems you are trying to solve.
myObject.addEventListener('myCustomEventTypeString', handler); myObject.dispatchEvent(new Event('myCustomEventTypeString')); myObject.removeEventListener('myCustomEventTypeString', handler);
globalBroadcaster.subscribe('myCustomEventTypeString', handler); globalBroadcaster.publish('myCustomEventTypeString', paramsArray); globalBroadcaster.unsubscribe('myCustomEventTypeString', handler);
myObject.myCustomEventType.add(handler); myObject.myCustomEventType.dispatch(param1, param2, ...); myObject.myCustomEventType.remove(handler);
As most things in life each solution has its pros and cons. It's your task to decide which approach fits better what you are trying to accomplish. I hope this information helps you on your decision. No solution is perfect for all cases.
Last edited by James M. Greene,