Re:After a year of using Node.js in production
by Touche on Monday May 02, 2016 @06:25PM
(#11616227)
Please don't use event streams for handling asynchronous code, that's not what it's for.
[ Parent
| on HN ]
Re:After a year of using Node.js in production
by sockgrant on Monday May 02, 2016 @07:18PM
(#11616574)
Can you elaborate?
Re:After a year of using Node.js in production
by Touche on Monday May 02, 2016 @07:21PM
(#11616598)
Event streams are similar to Promises in that they provide a value for something that will happen in the future. In the case of event streams it is a value for an event. In the browser this might be a user clicking a button. This event can occur many times. It might never occur. Promises are values for something that will happen in the future, but only once.
Use Promises for things that happen once, event streams for things that happen 0 to many times.
Re:After a year of using Node.js in production
by rescripting on Monday May 02, 2016 @08:58PM
(#11617059)
I'm not sure I'm seeing your argument against using promises over observables for single events. Observables are a superset of promises, sure, but you can map them into situations where you'd use promises and then still have the flexibility of observables and all their operators. along with this you get the consistency of using the same async paradigm everywhere.
I find you run into trouble when you start mixing them. If you use observables for 0-N events and promises for 1 time events you're always converting between the two.