@legworkstudio/eventful
v1.0.0
Published
An event helper
Downloads
2
Readme
Eventful
A helper class for events.
Use
Listen:
_myObject.on('some-event', (event) => console.log(event) );
Trigger:
_myObject.trigger('some-event', {foo: bar, fizz: buzz, data: {} });
_myObject.trigger('some-other-event');
Detach:
_myObject.off('some-event');
With Eventful you can attach listeners to any object that you have access to and transfer data between the caller and the object.
Returns
Will return an object with the event and any data associate with that event.
Methods
on('event-type')
: Attach an event (string)
off('event-type')
: Detaches an event that has been attached (string)
trigger('event-type', {})
: Triggers an event (string, data)
Tests
To run tests npm test