123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- Event manager - revamp
- //Current status:
- //flat event listener
- var ctx = {};
- function callback() {};
- // ctx allows for easy removal of several events
- events.on(ctx,'core-shell:cmd:ls',callback);
- events.on(ctx,'hci-http:req:/monitor/?(.*)',callback);
- events.listeners = [
- (Listener): { context,'core-shell:cmd:ls',callback,order}
- (Listener): { context,'hci-http:req:/monitor/?(.*)',callback,order}
- ];
- //So when an event is fired, the listeners will be iterated and checked
- context.emit(name,...args);
- events.emit('core-shell:cmd:ls',1,2);
-
- // Contextual idea
- //
- var ctx = events.createContext();
- ctx.on('core-shell:cmd:ls',callback);
- 10000 listeners testing cases
- Goal:
- Maintain listeners even if module is gone
- improve performance on listener matching
- //
- var subscription = context.subscribe('hci-http')
- subscription.on('get:/monitor/?(.*)');
- subscription.on('post:/monitor');
- Right now if we receive a request from /monitor/api we broadcast it to anyone that's listening for hci-http
- meaning with
- as of hci-http-monitor
|