Kind: global class
- Wevent
- new Wevent([weakMap])
- .on(object, eventListener) ⇒
function
- .off(object, [eventListener]) ⇒
boolean
- .emit(object, ...emitArguments) ⇒
Promise
- .count(object, [eventListener]) ⇒
number
Construct Wevent object
Param | Type | Description |
---|---|---|
[weakMap] | WeakMap |
WeakMap to use as storage, mainly used for global object. |
Bind event listener to object. You can bind to this function as well, the emitted arguments are : (off function for this on), (object listened on), (event listener supplied).
Kind: instance method of Wevent
Returns: function
- Off function tied directly to recently bound
event listener.
Param | Type | Description |
---|---|---|
object | Object |
Object to bind the event listener to. |
eventListener | function |
Event listener to bind. |
Unbind event listener on object. You can bind to this function as well, the emitted arguments are : (did off result in removing), (object unlistened), (event listener supplied).
Kind: instance method of Wevent
Returns: boolean
- Did the off remove event listener(s).
Param | Type | Description |
---|---|---|
object | Object |
Object to unbind event listener from. |
[eventListener] | function |
Event listener to unbind, if none given unbinds all event listeners on the given object. |
Emit an event on object. You can bind to this function as well, the emitted arguments are : (count emitted), (object emitted to), (...emit arguments).
Kind: instance method of Wevent
Returns: Promise
- Promise when emit has finished on all event listeners.
Param | Type | Description |
---|---|---|
object | Object |
Object to emit to. |
...emitArguments | * |
Arguments to pass to event listeners. |
Returns distinct event listener count for given object or optionally count for given event listener count on object.
Kind: instance method of Wevent
Returns: number
- Count.
Param | Type | Description |
---|---|---|
object | Object |
Object to query the count for. |
[eventListener] | Object |
Optional event listener to get count from. |