0.0.2 • Published 7 years ago

@archjs/event-notifier v0.0.2

Weekly downloads
1
License
ISC
Repository
gitlab
Last release
7 years ago

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 git@gitlab.com: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();