Hacker News new | past | comments | ask | show | jobs | submit login

Agreed. Checkout RxJS to hold you over while you're in Javascript land.



Please don't use event streams for handling asynchronous code, that's not what it's for.


Can you elaborate?


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.


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.


Yep. We used to do both, but that was convoluted, so only Rx now.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: