I've several events which I need to listen to with additional event and pass object:
const spawn = require('child_process').spawn;
const ls = spawn('ls', ['-lh', '/usr']);
ls.stderr.on('data', (data) => {
myObj.data = true
//here I need to raise the event with the property data
});
ls.on('close', (code) => {
myObj.close = true
//here I need to raise the event with the property close
});
For example inside of every event I want to emit my events and send object with property. For example raise myEvent with my object and every following event will update property in my object like data,close,open
Let's say this is my object
var myObj ={
open:true,
data:false,
close:true
}
How can I do this?