javascript - Node.js listen and emmit events -


i have 2 classes , want 1 class subscribed other. this.

class one:

while(1){ if(true){ //emmit event }

class two:

//wait class 1 emmit data ,and start working data

my question is, there method, module.. can me implemented behavior?

use node's built-in eventemitter implement emitting , listening events in both clients.

example:

const eventemitter = require('events');  class myemitter extends eventemitter {}  const myemitter = new myemitter(); myemitter.on('event', () => {    console.log('an event occurred!'); }); myemitter.emit('event'); 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

What is happening when Matlab is starting a "parallel pool"? -