4 ms·
Why is Rx so huge? What does it give you that Promises dont?
by omegaworks 10y ago
Why is Rx so huge? What does it give you that Promises dont?
- bsaul 10y agoThis http://rxmarbles.com http://rxmarbles.com will shows a little better the possibilities of combining rx streams. Now carefull, because it adds a lot of complexity, sometimes for very little gain, and sometimes for even harder to debug code. It also has a high learning curve, because it encourages you to make your code declarative rather than imperative, which isn't always obvious to do.
- barrkel 10y agoPromises let you compose a program to eventually process a single result. They're oriented around a single event. Observables let you compose a program to process a stream of values. In practice, there's an abstraction jump with observables. Promise compositions are usually built in response to an imperative action. Observables are built to replace imperative event handlers altogether.
- dtech 10y agoPromises are to Streams what single values are to arrays/collections. Promises are all fine and dandy for "do this, wait for that, do that", but they are not powerful enough to express "every time this happens, do that". I guess you're coming from a JS background as you are using the word "Promises". Imagine instead of registering a callback for mouse click events, you have a stream of mouse events where you can listen to. This is exactly how it works in Angular 2 [1]. [1] http://blog.rangle.io/observables-and-reactive-programming-in-angular-2/ http://blog.rangle.io/observables-and-reactive-programming-i...