- Marble diagrams are awesome and show the streams really well. When you cannot fit them due to space constraints - time to refactor
- Testing Rx.js code is still hard and requires controlling timing of events. See https://glebbahmutov.com/blog/testing-reactive-code/
- Reactive is all about controlling sequence of events. A simple operation might be take
In its first form it just takes N items s.take(2)
which creates second stream with first 2 events from s
and the completes. But what happens if you don't know how many items to take? Maybe there is a condition,
a simple function that operates on the event data and/or global state that tells when to stop taking items.
In this case takeWhile
is useful s.takeWhile(x => x < 10)
But what if you want to have more complex control and synchronize two streams. Maybe you want to take events
from s
until another stream emits an event. This would be useful if the second stream were a promise as well.
Use takeUntil and
write s.takeUntil(Observable.from(promise))
.
This is common in Rx5 - there is a simple "constant" method, another one for synchronous control and third one for controlling from another stream. An example are "buffer", "delay", "skip" methods
- Cold vs hot observables is always a nice topic for discussion. I now lean towards hot observables and would advise looking at xstream library where everything is hot by default.