@binart/jx-event
v1.0.2
Published
Eventing for javascript.
Downloads
1
Readme
Event Handling
Usage
import {Event} from 'jx-cores';
var eventor = new Event()
eventor.on('on.some.thing.happen', function () {
// do something
});
eventor.emit('on.some.thing.happen')
eventor.once('on.some.thing.happen.and.expire', function () {
// do it once
});
eventor.emit('on.some.thing.happen.and.expire')
eventor.emit('on.some.thing.happen.and.expire')
var handler = function (){}
var handler1 = function (){}
eventor.on('on.another.thing.happen', handler);
eventor.on('on.another.thing.happen', handler1);
eventor.off('on.another.thing.happen', handler);
eventor.offAll('on.another.thing.happen');
eventor.count('on.another.thing.happen'); // 0