emitevent
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

EmittEvent

A Basic eventemitter writen in Ecmascript 6 modeled on Node.js EventEmitter. It sure wouldn't work in old browsers, but it's good enough to do the job.

Documentation

eventsNames()

Return an array of all event's names/types

  • Returns: (Array|null)

eventListeners(evnt)

return all listeners of a given event if it exist, else null.

  • Parameters: evntString — The event name.
  • Returns: (Array|null)

addListener(evnt, fn, once)

Add new event if it doesn't exist, else add it to existing one

  • Parameters:
    • evntString — The event name.
    • fnFunction — The Callback / Listener function
    • onceboolean — If Callback / Listener should run once

removeListener(evnt, fn)

Remove listeners of a given event. All listenres that match the Callback fn will be removed

  • Parameters:
    • evntString — The event name.
    • fnFunction — Function to identify the listener with.

clearEvent(evnt)

Removes the event and all its listeners.

  • Parameters: evntstring — The event name.

on(evnt, fn)

Add a listener

  • Parameters:
    • evntstring — The event name.
    • fnfn — The Callbacl function

emit(evnt)

Calls all listenres of a given event.

  • Parameters: evntString — The event name.
  • Returns: Booleantrue if the event had listeners, else false.

Package Sidebar

Install

npm i emitevent

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

8.02 kB

Total Files

6

Last publish

Collaborators

  • yelrhilassi