Standalone vs sockets inside an express router


I’m new to sockets and I’m trying to figure out the pros and cons of these two implementations.

Why emit events using inside an express route handler then just using a listener and emit events through it without an express route?


The main difference is that using inside an express route handler gives you more control over the data that is being emitted. For example, you can easily add middleware to an express route handler to validate data before emitting it.

Another difference is that using a listener gives you more flexibility in terms of where you can put your code. For example, you could put your listener inside a separate module and then require it in your express route handler.

Answered By – HydroxZ

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published