Is it good to set action type condition inside a custom redux middleware? #4291
slamdunkYYY
started this conversation in
General
Replies: 1 comment 2 replies
-
I'm not quite sure what the exact question is here. However, I'd recommend taking a look at our new "listener middleware", which looks like it can do the kinds of things you're asking about: |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm going to create a custom redux. And based on the different scenarios, I'll do some extra inside the middleware.
I have two options to detect check the condition. Option 1 is checking the action type and based on the action type, to do the extra action.
Another option is instead of set condition inside middleware, I will do something on the action, I add some extra property to the original action.
So the custom middleware will be:
for actions, if the original action object is
{ type: 'TYPE1', payload: 'abc' }
, with those I want to do something extra, I will modify it to{ type: 'TYPE1', payload: 'abc', extraAction: true }
. But for those not with extra, I will leave them as the old, like{ type: 'TYPE2', payload: 'abcd' }
without the extra property.I want to know which way is better.
Beta Was this translation helpful? Give feedback.
All reactions