question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to dispatch more actions in 1 yield via PUT

See original GitHub issue

Why is redux-saga not dispatching action when used in this form:

function* updatePorts(action) {
    const {response} = yield SagaEffects.call(apiUpdatePorts, action.ports);
    if (response) {
        yield (() => {
            console.log("Dispatching - ", action.actionAfter);
            SagaEffects.put(action.actionAfter);
        })();

But it works in this manner:

function* updatePorts(action) {
    const {response} = yield SagaEffects.call(apiUpdatePorts, action.ports);
    if (response) {
        yield SagaEffects.put(action.actionAfter);

I would like to dispatch 2 actions in 1 yield thats why I am trying to use the arrow function (() => {}).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

59reactions
kyle-ssgcommented, Oct 29, 2018

This post ranks high in google for this question, so thought I’d mention the above is deprecated and that you now want to do:

yield SagaEffects.all([
            SagaEffects.put(actions.saveItemsOk()),
            SagaEffects.put(actionsButton.savingEnded())
        ])
41reactions
zatzikycommented, Apr 8, 2019

⚠ see @kyle-ssg 's answer below. This one is depricated

@slorber It worked. I used it this way:

yield [
            SagaEffects.put(actions.saveItemsOk()),
            SagaEffects.put(actionsButton.savingEnded())
        ]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Dispatching Actions | Redux-Saga
Dispatching actions to the store. Taking the previous example further, let's say that after each save, we want to dispatch some action to...
Read more >
Javascript: Redux: Dispatching Multiple Actions - Medium
The answer of course is, yes, just either call dispatch multiple times or iterate dispatch over an array. Usually, though, if you're dispatching...
Read more >
Can I dispatch multiple actions from Redux action creators?
Actually, this is a trick question; with the appropriate store middleware, it is possible to do both at once! How does this work?...
Read more >
Different Ways to Dispatch Actions with Redux - Pluralsight
The dispatch method is available on the store object. An action gets dispatched to trigger an update to the Redux store. 1// App.js ......
Read more >
Chaining Asynchronous Dispatches in Redux Toolkit - YouTube
In this video I cover how we can correctly dispatch one action after another, where the second dispatch is informed by the state...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found