New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update docs to warn about subscribing directly to state$ #766
Comments
More info here: redux-observable#766 Not sure if it's worth adding workarounds as it's quite an edge case. Could potentially say it's isn't advised the the action is also needed?
Interesting. I haven't come across anyone with this pattern of That said, I'm keeping an open mind! If you're still interested in this topic, would you mind elaborating on some patterns you think are better using Side note: is |
The use case is probably one of the more complex with multiple slices which are combined and re-used in multiple sub applications. The main reason for favoring state is because it's the source of truth, we have found relying on a specific action can become fragile because of the following:
These cases aren't applicable to every application or even every slice, but to avoid accidents our rule of thumb is to avoid using the action$ directly. I imagine this is unlikely to be an issue for most usages, so I think it's fine to advise against it, but it would be nice to be explicit about the ordering in the docs. Happy to discuss further if you are interested. (Sorry I meant pluck not pick :) good spot ) |
Feature request for docs
What is the current behavior?
Subscribing to the state$ can be problematic if you later rely on the current value of the action$.
It is intended that the
state$
emits first, as most examples suggest starting with a subscription to theaction$
, however if someone chooses to subscribe to thestate$
they should be away that pulling in the currentaction$
value withcombineLatest()
will be incorrect (it will be the previous value).What is the expected behavior?
This is expected (I can't think of a logical alternative), however it's not obvious and can be really confusing.
Suggested work around in the docs:
The above is slightly nicer than:
or you could (but a less reactive approach)
Which versions of redux-observable, and which browser and OS are affected by this issue? Did this work in previous versions of redux-observable?
All
The text was updated successfully, but these errors were encountered: