@archjs/event-notifier
v0.0.2
Published
Event based on ReactiveX Subject
Downloads
16
Readme
event-enotifier
Info
language: typescript
module type: commonjs
dependncies: rxjs
description: Event emitter/notifier class using rxjs/Subject as events.
Instalation
npm install @archjs/event-notifier
package.json
{
...
dependencies:{
...
"@archjs/event-notifier": "*",
...
}
...
}
development install
git clone [email protected]:softem/archjs/core/event-notifier.git
Usage
creation
import {EventNotifier} from '@archjs/event-notifier/EventNotifier';
var norifier = new EventNotifier(); // no cosntructor parameters
var norifier = new EventNotifier(['click','change']); //constructor with events
Register new event to notifier
notifier.createEvent('myCustomEventName');
Attach new observer to event
notifier.on('myCustomEventName', function(data){
console.log('myCustomEventName triggered');
});
Trigger event
notifier.trigger('myCustomEventName', { name:'myCustomEventName' } );
Unsubscribe
var observer = notifier.on('myCustomEventName', function(data){
console.log('myCustomEventName triggered');
});
observer.unsubscribe();