performance.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. Event manager - revamp
  2. //Current status:
  3. //flat event listener
  4. var ctx = {};
  5. function callback() {};
  6. // ctx allows for easy removal of several events
  7. events.on(ctx,'core-shell:cmd:ls',callback);
  8. events.on(ctx,'hci-http:req:/monitor/?(.*)',callback);
  9. events.listeners = [
  10. (Listener): { context,'core-shell:cmd:ls',callback,order}
  11. (Listener): { context,'hci-http:req:/monitor/?(.*)',callback,order}
  12. ];
  13. //So when an event is fired, the listeners will be iterated and checked
  14. context.emit(name,...args);
  15. events.emit('core-shell:cmd:ls',1,2);
  16. // Contextual idea
  17. //
  18. var ctx = events.createContext();
  19. ctx.on('core-shell:cmd:ls',callback);
  20. 10000 listeners testing cases
  21. Goal:
  22. Maintain listeners even if module is gone
  23. improve performance on listener matching
  24. //
  25. var subscription = context.subscribe('hci-http')
  26. subscription.on('get:/monitor/?(.*)');
  27. subscription.on('post:/monitor');
  28. Right now if we receive a request from /monitor/api we broadcast it to anyone that's listening for hci-http
  29. meaning with
  30. as of hci-http-monitor