Passing dispatch to saga
See original GitHub issueI have a situation where I’d like to use dispatch
within a nested callback of an async ajax response, outside of the typical generator flow. I was wondering if you saw any problems with changing this line in middleware.js
from:
sagas.forEach(runSaga)
to:
sagas.forEach(runSaga.bind(null, dispatch))
so dispatch would be received by the root saga(s) and it’d be possible to then pass this along to additional functions which operate outside of the generator runtime.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Dispatching Actions | Redux-Saga
This way we can test the Generator's dispatch in the same way: by inspecting the yielded Effect and making sure it contains the...
Read more >Different Ways to Dispatch Actions with Redux - Pluralsight
Passing dispatch method to our component. The dispatch method is available on the store object. An action gets dispatched to trigger an ...
Read more >Access to store.dispatch in a saga for use with react router redux
Any ideas on how to access store.dispatch within a saga? I know you can pass arguments in the root saga but I don't...
Read more >Understanding Redux Saga: From action creators to sagas
Since the middleware automatically passes the dispatch function to the function that the action creator returns, there is no difference ...
Read more >Introduction to Redux Saga | LoginRadius Blog
Redux Thunk, a common alternative to Redux Saga, allows functions to be passed into the Redux store dispatch, which checks to see if...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Arguments are passed here.
Using the dynamic running API. Can’t the following solve your issue ?
configureStore.js
main.js
I’ve just found the way. With the
wrapObservable
helper from the https://github.com/eggers/async-generator package we can do: