Composing actions
See original GitHub issueWith redux-thunk I can dispatch(actionA).then(() => dispatch(actionB))
. For example, I have a form that I want to populate with initial values. Dispatching actionA
allows me to get these initial values (by sending an async fetch). Dispatching actionB
initializes the form with these values.
With sagas I can’t do the above, because dispatches don’t return promises. I have to create a new action - actionAandB
- along with a new saga that combines the logic of actionA
and actionB
. Is there a more idiomatic way to do this instead of creating a new action, and a new saga for that action?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Actions | Vuex
Actions are often asynchronous, so how do we know when an action is done? And more importantly, how can we compose multiple actions...
Read more >Scala Actions Composition - 2.8.x - Play Framework
While action composition allows you to perform additional processing at the HTTP request and response level, often you want to build pipelines of...
Read more >Creating a composite action - GitHub Docs
In this guide, you'll learn how to build a composite action. Introduction. In this guide, you'll learn about the basic components needed to...
Read more >Composing Actions - NgRx Auto-Entity - GitBook
When developing complex applications, sometimes it may help to "bundle" multiple actions together or compose many individual actions into sort of a higher ......
Read more >Composing actions with Vuex - codeburst
Composing actions with Vuex. Introduction to implementing complex actions using Vuex, the Vue.js state management library.
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
So, you are dispatching promises, because fetchNote(id) is likely to return a promise. Thus please try what I have written above and if this does not work open a feature request
If your dispatch function returns promise, it’s probably because you use some promise middleware.
It is possible to wait for promises in redux-saga, have you tried the following?
I’m not sure if currently the put effect does return the result of the dispatch method however but you can try that.
Also, why do you want to mix redux-saga code with promise middleware? If you start to use sagas you would tend to dispatch only synchronous actions and manage effects inside sagas directly.