Skip to content

Latest commit

 

History

History
84 lines (59 loc) · 2.15 KB

API.md

File metadata and controls

84 lines (59 loc) · 2.15 KB

API doc

class: Evemit

new Evemit()

Evemit constructor.

evemit.on(event, fn, [context])

Register a new event listener for a given event.

Params

  • event string - Event name.
  • fn function - Callback function (listener).
  • [context] * - Context for function execution.

Returns: Evemit - Current instance.

evemit.once(event, fn, [context])

Add an event listener that's only called once.

Params

  • event string - Event name.
  • fn function - Callback function (listener).
  • [context] * - Context for function execution.

Returns: Evemit - Current instance.

evemit.emit(event, [...arg])

Emit an event to all registered event listeners.

Params

  • event string - Event name.
  • [...arg] * - One or more arguments to pass to the listeners.

Returns: bool - Indication, true if at least one listener was executed, otherwise returns false.

evemit.off(event, fn)

Remove event listeners.

Params

  • event string - The event to remove.
  • fn function - The listener that we need to find.

Returns: Evemit - Current instance.

evemit.listeners([event])

Get a list of assigned event listeners.

Params

  • [event] string - The events that should be listed. If not provided, all listeners are returned. Use the property Evemit.events if you want to get an object like
{event1: [array of listeners], event2: [array of listeners], ...}

Returns: array

Evemit

Minimal and fast JavaScript event emitter for Node.js and front-end.

Author: Nicolas Tallefourtane [email protected]
License: MIT https://github.com/Nicolab/evemit/blob/master/LICENSE