propagation.js 499 B

123456789101112131415161718192021222324252627282930
  1. var Eventual = require('../../lib/eventual');
  2. var events = new Eventual();
  3. var ctx = events.createContext();
  4. ctx.on('hello:from:the',(e) => {
  5. e.wait();
  6. console.log("Will be done in a sec");
  7. setTimeout(() => {
  8. console.log("Continue");
  9. e.done();
  10. },1000);
  11. });
  12. ctx.on('hello:from',(e) => {
  13. console.log("The other side");
  14. e.stop();
  15. });
  16. ctx.on('hello',(e) => {
  17. console.log("Worked");
  18. });
  19. ctx.propagate('hello:from:the:other:side')
  20. .done(() => {
  21. console.log("Events called");
  22. });