I want to get all progress and updates of loop from this object method. I have used eventEmitter to emit a message and then catch that signal with .on like this:
let response= site_ob.getAllProducts();
response.on(('gotit'),(data)=>{
console.log("data");
});
But it shows response.on is not a function.
Below is a method of a class:
async getAllProducts(){
const eventEmitter=new EventEmitter();
let ended=false,products_array = [],count=0,promises_array = [];
let total_products_num=this.getTotalProductNumbers();
for(let i=0;i<=150;i+=50) {
let products_data= await this.getProducts(i, 50);
products_array.push(products_data);
eventEmitter.emit('gotit', products_data);
}
return products_array;
}
Or can I use pipe or stream to do this?