I have some variable let newBl = someFunction
which subscribing on some data coming, and I have declaring of some listener newBl.on('data',(data)=>{})
. I can remove this listener like newBl.off('data')
, but I need redeclare this this listener. Is there are some method for this like newBl.change()
or something like that?
You could create a separated function so you could reuse it withour repeating yourself like :
newBl.off('data').on('data',(data)=>{
common_function(data);
});
function common_function(data){
//Your logic
}