Skip to content

Idiomatic way to filter actions based on state when using builder? #2554

Answered by markerikson
samanpwbb asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not entirely sure what the point of that "short-circuiting" is in the first place, tbh, even in the old style. Is that intended to be a "state machine"-ish approach, where you only care about action X if the reducer's state is already in a certain condition? (see the "Detailed Explanation" expander at https://redux.js.org/style-guide/#treat-reducers-as-state-machines for an example of what I mean.)

If that really is what you want, then createSlice doesn't quite let you do that out of the box, because it's oriented around "handle this specific action type with this specific case reducer", and doesn't have a way to add some kind of a precondition in there.

I can think of a couple ways t…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@samanpwbb
Comment options

Answer selected by samanpwbb
Comment options

You must be logged in to vote
1 reply
@samanpwbb
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants