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
Hi! Just a comment/question about something I've seen in the dispatch's code in createStore.js (see the code below). I was wondering why is variable isDispatching needed, if there are two concurrent calls to dispatch the isDispatching check is pointless because is not inside a mutex:
But as far as I know, JS' runtime can only execute one thing/function at a time so two concurrent calls to dispatch will never happen and if that's the case I don't see the need for isDispatching right?
functiondispatch(action){// ...if(isDispatching){thrownewError('Reducers may not dispatch actions.')}try{isDispatching=truecurrentState=currentReducer(currentState,action)}finally{isDispatching=false}// ...}
The text was updated successfully, but these errors were encountered:
Oh I see, now is clear, is dispatching from within a reducer forbidden to avoid things such as loops (reducer -> dispatch -> reducer ->...) am I right?
Hi! Just a comment/question about something I've seen in the
dispatch
's code increateStore.js
(see the code below). I was wondering why is variableisDispatching
needed, if there are two concurrent calls todispatch
theisDispatching
check is pointless because is not inside a mutex:But as far as I know, JS' runtime can only execute one thing/function at a time so two concurrent calls to dispatch will never happen and if that's the case I don't see the need for
isDispatching
right?Can you tell me if I'm missing something? Thanks!
https://github.com/reactjs/redux/blob/master/src/createStore.js#L149
The text was updated successfully, but these errors were encountered: