You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a use case where given an action I might modify it, reject it, or do nothing to it. However, when I reject it I want to dispatch a new action in order to have some information persisted to the state.
I notice that transform only has the next/reject methods available to it, is there a technical reason why dispatch is not there?
Thanks for your time,
Ivo
The text was updated successfully, but these errors were encountered:
hyperivo
changed the title
Why not make dispatch available in transform?
Question: Why not make dispatch available in transform?
Feb 4, 2017
Jeff may have additional insight here, but you can optionally pass an action parameter to your reject() invocation.
There are different conditions, where the action can be:
the original action
one with a modified payload
a completely new action (i.e. different action type)
or no action parameter at all
I believe the third case will service your needs. If you call reject(newAction) redux-logic will basically kill the current action and re-dispatch the new one.
Kevin did a good job summarizing that. I appreciate it @KevinAst .
So yes, when you pass an action to accept or reject it will look at the type. If it is the same type it will internally call the middleware next handing it down to the rest of the middlewares and reducer. If it was a different type it will instead dispatch so that all necessary middleware will have a chance to see it. This behavior can be overridden with options but normally it is exactly what you want to happen (it also prevents the potential loops).
Hi @jeffbski,
I have a use case where given an action I might modify it, reject it, or do nothing to it. However, when I reject it I want to dispatch a new action in order to have some information persisted to the state.
I notice that transform only has the next/reject methods available to it, is there a technical reason why dispatch is not there?
Thanks for your time,
Ivo
The text was updated successfully, but these errors were encountered: