Prem
Prem

Reputation: 5997

What is the advantage of binding multiple event listeners to same event in Node.js

Consider the following example. When Binding a event listener to a event type can just fulfill the output, what is the significance of binding multiple event listeners to same even?

readStream.on("data", function(data) {console.log('I have some data here.');          
}); 
readStream.on("data", function(data) {console.log('I have some data here too.');
});

Upvotes: 1

Views: 607

Answers (1)

Paul
Paul

Reputation: 36339

Mostly it's for modularity. You wouldn't likely do that in the same file, unless you're defining your listener functions somewhere else and then composing them in one place.

Upvotes: 2

Related Questions