eventory
v1.1.9
Published
Event Hub.
Downloads
11
Readme
Event Hub
Event Hub provides event pub/sub.
Features:
- synchronized callback along all async handlers
- support Promises (promit)
- emission timeout
- keys with placeholder
- key-as-function
- defered emitting (await for postponed addition of listener)
Implementation
- written in JS6
- no extra dependencies
API
class EventHub
once(key, handler): ownerId
on(key, handler, ownerId): ownerId
offOwner(ownerId)
off(keyPrefix)
emit(key, {timeoutInSeconds:10, ...params}, [callback])
promit(key, {...params}).then((after)=>{})
Example
var hub = new EventHub();
hub.on('api', (params, cb)=> cb(null, params));
hub.emit('api', params, callback);
hub.off('api');
See test/test.js
for more use cases.
Repo
[https://github.com/alitskevich/eventhub]
Legal
The MIT License (MIT)
Copyright (c) 2015 Alex Litskevich