Skip to content
This repository has been archived by the owner on Dec 17, 2022. It is now read-only.

Latest commit

 

History

History
76 lines (59 loc) · 2.98 KB

api.md

File metadata and controls

76 lines (59 loc) · 2.98 KB

Wevent

Kind: global class

new Wevent([weakMap])

Construct Wevent object

Param Type Description
[weakMap] WeakMap WeakMap to use as storage, mainly used for global object.

wevent.on(object, eventListener) ⇒ function

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.

wevent.off(object, [eventListener]) ⇒ boolean

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.

wevent.emit(object, ...emitArguments) ⇒ Promise

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.

wevent.count(object, [eventListener]) ⇒ number

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.