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
My requirement is dispatch array of actions at the same time. I am doing this by using Higher Order Store.
I wrapped dispatch method and resolved it. Now my code is,
function dispatch(actions) {
if (typeof actions.type === 'undefined') {
throw new Error(
'actions may not have an undefined "type" property. ' +
'Have you misspelled a constant?'
)
}
if (isDispatching) {
throw new Error('Reducers may not dispatch actions.')
}
try {
isDispatching = true
if (Array.isArray(actions)){
actions.forEach(action=>{
currentState = currentReducer(currentState, action);
})
}else if (typeof actions === 'object'){
currentState = currentReducer(currentState, actions);
}
} finally {
isDispatching = false
}
const listeners = currentListeners = nextListeners
for (let i = 0; i < listeners.length; i++) {
const listener = listeners[i]
listener()
}
return actions;
}
If you have added this feature to Redux's dispatch method helpful for us.
The text was updated successfully, but these errors were encountered:
See the very long prior discussion in #1813 for more info on this.
I recommend using the redux-batch store enhancer at https://github.com/manaflair/redux-batch if you're looking to dispatch an array of actions with only a single subscriber notification. There's also a variety of other approaches for batching (higher-order reducers, middleware, etc). See the Store#Batching and Notifications section of my Redux addons catalog for links to other batching-related libraries.
My requirement is dispatch array of actions at the same time. I am doing this by using Higher Order Store.
I wrapped dispatch method and resolved it. Now my code is,
If you have added this feature to Redux's dispatch method helpful for us.
The text was updated successfully, but these errors were encountered: