##hole fire in the hole,simple yet event library,dead simple,enjoy it ^_^
~ npm install hole-event
Register a specific callback to be called when eventType is trigger,return a token,alias bind
hole.on('a.b.c',function(){
console.log(arguments);
});
hole.fire('a.b.c');
//or
hole.bind('a.b.c',function(){
console.log(arguments);
});
var token = hole.on('a.b.c.d',function(){});
token.fire();//token.emit();token.trigger();
Similar to on
but the callback just be invoked once
hole.once('a.b.c.d',function(){
console.log(arguments);
})
hole.fire('a.b.c',9527);//log
hole.fire('a.b.c',9527);//nothing
Remove registered listener by eventType,alias unbind
hole.off('a.b.c')
//or
hole.unbind('a.b.c')
Removes all of the registered listeners.
hole.clear();
If eventType has been registered ,will return true,otherwise return false
hole.has('a.b.c');
Emits an event of the given type with the given data,alias fire
、trigger
、hole
hole.emit('a.b.c')
//or
hole('a.b.c')
//or
hole.fire('a.b.c')
//or
hole.trigger('a.b.c')
eventType supports wildcard,it is so cool!!
hole.on('a.b.*',function(){
});
hole.fire('a.*');
test