Do the design of ActionsObservable and StateObservable make sense with RxJS 6 thinking?
See original GitHub issueI noticed that these observables are going to remain in existence (or exist in the case of StateObservable) but they kind of go counter to the new way of creating Observables in RxJS 6. The static class methods are all going away in favor of creation functions. So instead of exporting the ActionsObservable
you change the documentation to show a user how to use rxjs
ās of
and from
? The ones on the ActionsObservable
seem to be pass-throughs.
As for the StateObservable
I canāt say thatās as straightforward but itād be nice to have the creation method pattern for both be like using the creation functions from RxJS 6. Iām sorry if Iām unclear here. Iām trying to read through the sources to see if Iām understanding right and working on a wip branch to migrate to RxJS 6 and redux-observable 1 so I wanted to make sure I migrate my tests idiomatically. š
Which versions of redux-observable, and which browser and OS are affected by this issue? Did this work in previous versions of redux-observable?
1.0.0alpha2
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:17 (8 by maintainers)
š Youāre definitely correct thanks for kicking off the discussion and helping out š
I plan to remove ActionsObservable entirely, but StateObservable is needed because it differs in behavior than any other built-in Observable or Subject. Itās similar to BehaviorSubject except that it does not require an initial value. This is required because we setup your epics before the first action has been dispatched, so that you donāt miss it. If we used a BehaviorSubject and an epic subscribes to it on setup, it would receive undefined.
Having a creation function makes sense but Iāve struggling with naming since the simple names usually used might be confusing in this case. Any suggestions?
@Pappa youāve actually found a bug in rxjs that was indeed introduced as part of rxjs#3504. That PR intended to only skip subscribing to the source if the notifier emits a value synchronously but instead skips subscribing if the notifier completes synchronously.
Iāve made a PR to fix this upstream: https://github.com/ReactiveX/rxjs/pull/4039
Until this is fixed, the solution is to make each action emitted async by scheduling using the AsyncScheduler. In the case of
ActionsObservable.of()
it can be provided as the last argument.If youāre using redux-observable v1 and rxjs v6 you also no longer need to use ActionsObservable, you could just use regular Observable
of()
fromimport { of } from 'rxjs'
Hereās a stackblitz: https://stackblitz.com/edit/redux-observable-v1-playground-ewvnvq?file=index.js
This works because the action$ stream wonāt synchronously complete then.