-
Notifications
You must be signed in to change notification settings - Fork 178
Home
millermedeiros edited this page Nov 27, 2010
·
12 revisions
A Signal is similar to a EventTarget/EventDispatcher or a pub/sub system, the main difference is that each event kind has it's own controller and doesn't rely on strings to call proper callbacks. To know more about differences check the Wiki page.
This implementation is heavily inspired by Robert Penner's AS3-Signals but it has a different set of features (some extra features and some missing), some methods also were renamed, the main focus is custom events and not replacing native DOM events.
- Arbitrary number of parameters to event handlers;
- Convenience methods that usually aren't present on other implementations of the observer pattern:
-
disable();
- disable event dispatching. -
enable();
- enable event dispatching. -
removeAll();
- remove all event listeners attached to specific event type. -
addOnce();
- automatically remove listener after first execution.
-
- Option to bind an execution context to the event handler avoiding scope issues that are really common in JavaScript.