Call actions sequentially in Redux Saga (synchronously)Pros/cons of using redux-saga with ES6 generators vs redux-thunk with ES2017 async/awaitHow to achieve callbacks in Redux-Saga?takeLatestHelper has been cancelled in redux-saga-effectsUsing React, why is redux saga not intercepting the action?throttle redux-saga based on action contentRedux Sagas - dispatch undefinedRedux Saga - How to call multiple actions after logging inReact redux-saga on server side doesn't take action after browser reloadRedux saga: internals of how redux-saga worksHow to call redux-saga action continuously after every 60 seconds

What is this opening trap called, and how should I play afterwards? How can I refute the gambit, and play if I accept it?

How to append a matrix element by element?

Does image quality of the lens affect "focus and recompose" technique?

Fedora boot screen shows both Fedora logo and Lenovo logo. Why and How?

Transition from ascending to descending a rope

Was touching your nose a greeting in second millenium Mesopotamia?

Is it okay to visually align the elements in a logo?

Declining an offer to present a poster instead of a paper

Why does the numerical solution of an ODE move away from an unstable equilibrium?

Is there any set of 2-6 notes that doesn't have a chord name?

How risky is real estate?

How dangerous are set-size assumptions?

Should my manager be aware of private LinkedIn approaches I receive? How to politely have this happen?

How many satellites can stay in a Lagrange point?

Is there a maximum distance from a planet that a moon can orbit?

Is this one of the engines from the 9/11 aircraft?

How can Charles Proxy change settings without admin rights after first time?

Layout of complex table

How can I convince my reader that I will not use a certain trope?

Is there a short way to compare many values mutually at same time without using multiple 'AND'-s?

How well known and how commonly used was Huffman coding in 1979?

Links to webpages in books

Is my Rep in Stack-Exchange Form?

Are neural networks the wrong tool to solve this 2D platformer/shooter game? Is there a proven way to frame this problem to a neural network?



Call actions sequentially in Redux Saga (synchronously)


Pros/cons of using redux-saga with ES6 generators vs redux-thunk with ES2017 async/awaitHow to achieve callbacks in Redux-Saga?takeLatestHelper has been cancelled in redux-saga-effectsUsing React, why is redux saga not intercepting the action?throttle redux-saga based on action contentRedux Sagas - dispatch undefinedRedux Saga - How to call multiple actions after logging inReact redux-saga on server side doesn't take action after browser reloadRedux saga: internals of how redux-saga worksHow to call redux-saga action continuously after every 60 seconds






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I want to refresh a list of items after I made some changes they are different endpoints to hit, and they need to be synchronous (I want to call the second function after getting the first function response).



After getting the response from inviteUsers() action, I would like to call getAllUsers() action to get the updated list.



My question is, what is the best practice to handle those sequentially calls? Should I add another saga to listen for the INVITE_USERS_SUCCESS and then call the second action, or should I call the getAllUsers() action inside the inviteUsers() action like this?:



// first action
function* inviteUsers(args)
try
yield call(() => API.post('/users/invite', args));

yield put(
type: CustomConstants.INVITE_USERS_SUCCESS
);

// call second action
yield call(getAllInvites);
catch (e)
yield put(
type: CustomConstants.INVITE_USERS_FAILURE,
error: e,
);



// second action (after first action response)
function* getAllInvites()
try
yield call(() => API.get('/users/all-invites'));

yield put(
type: CustomConstants.LIST_PENDING_INVITES_SUCCESS
);
catch (e)
yield put(
type: CustomConstants.LIST_PENDING_INVITES_FAILURE,
error: e,
);











share|improve this question




























    0















    I want to refresh a list of items after I made some changes they are different endpoints to hit, and they need to be synchronous (I want to call the second function after getting the first function response).



    After getting the response from inviteUsers() action, I would like to call getAllUsers() action to get the updated list.



    My question is, what is the best practice to handle those sequentially calls? Should I add another saga to listen for the INVITE_USERS_SUCCESS and then call the second action, or should I call the getAllUsers() action inside the inviteUsers() action like this?:



    // first action
    function* inviteUsers(args)
    try
    yield call(() => API.post('/users/invite', args));

    yield put(
    type: CustomConstants.INVITE_USERS_SUCCESS
    );

    // call second action
    yield call(getAllInvites);
    catch (e)
    yield put(
    type: CustomConstants.INVITE_USERS_FAILURE,
    error: e,
    );



    // second action (after first action response)
    function* getAllInvites()
    try
    yield call(() => API.get('/users/all-invites'));

    yield put(
    type: CustomConstants.LIST_PENDING_INVITES_SUCCESS
    );
    catch (e)
    yield put(
    type: CustomConstants.LIST_PENDING_INVITES_FAILURE,
    error: e,
    );











    share|improve this question
























      0












      0








      0








      I want to refresh a list of items after I made some changes they are different endpoints to hit, and they need to be synchronous (I want to call the second function after getting the first function response).



      After getting the response from inviteUsers() action, I would like to call getAllUsers() action to get the updated list.



      My question is, what is the best practice to handle those sequentially calls? Should I add another saga to listen for the INVITE_USERS_SUCCESS and then call the second action, or should I call the getAllUsers() action inside the inviteUsers() action like this?:



      // first action
      function* inviteUsers(args)
      try
      yield call(() => API.post('/users/invite', args));

      yield put(
      type: CustomConstants.INVITE_USERS_SUCCESS
      );

      // call second action
      yield call(getAllInvites);
      catch (e)
      yield put(
      type: CustomConstants.INVITE_USERS_FAILURE,
      error: e,
      );



      // second action (after first action response)
      function* getAllInvites()
      try
      yield call(() => API.get('/users/all-invites'));

      yield put(
      type: CustomConstants.LIST_PENDING_INVITES_SUCCESS
      );
      catch (e)
      yield put(
      type: CustomConstants.LIST_PENDING_INVITES_FAILURE,
      error: e,
      );











      share|improve this question














      I want to refresh a list of items after I made some changes they are different endpoints to hit, and they need to be synchronous (I want to call the second function after getting the first function response).



      After getting the response from inviteUsers() action, I would like to call getAllUsers() action to get the updated list.



      My question is, what is the best practice to handle those sequentially calls? Should I add another saga to listen for the INVITE_USERS_SUCCESS and then call the second action, or should I call the getAllUsers() action inside the inviteUsers() action like this?:



      // first action
      function* inviteUsers(args)
      try
      yield call(() => API.post('/users/invite', args));

      yield put(
      type: CustomConstants.INVITE_USERS_SUCCESS
      );

      // call second action
      yield call(getAllInvites);
      catch (e)
      yield put(
      type: CustomConstants.INVITE_USERS_FAILURE,
      error: e,
      );



      // second action (after first action response)
      function* getAllInvites()
      try
      yield call(() => API.get('/users/all-invites'));

      yield put(
      type: CustomConstants.LIST_PENDING_INVITES_SUCCESS
      );
      catch (e)
      yield put(
      type: CustomConstants.LIST_PENDING_INVITES_FAILURE,
      error: e,
      );








      redux-saga






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 10:56









      jamesjames

      224 bronze badges




      224 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          1















          Should I add another saga to listen for the INVITE_USERS_SUCCESS and then call the second action




          Yes, you should. You get the best of Redux-saga when you use only actions to trigger them and, more in general, to make them communicate (it's event-driven development).



          This brings you to write more code but also to develop independent sagas.




          or should I call the getAllUsers() action inside the inviteUsers() action




          I don't recommend you to do that because your inviteUsers saga won't be decoupled from the getAllUsers one (because they are part of a bigger flow) and you won't be able to use them separately when you need a different flow.



          Let me know if you need some more help 😉






          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55336239%2fcall-actions-sequentially-in-redux-saga-synchronously%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1















            Should I add another saga to listen for the INVITE_USERS_SUCCESS and then call the second action




            Yes, you should. You get the best of Redux-saga when you use only actions to trigger them and, more in general, to make them communicate (it's event-driven development).



            This brings you to write more code but also to develop independent sagas.




            or should I call the getAllUsers() action inside the inviteUsers() action




            I don't recommend you to do that because your inviteUsers saga won't be decoupled from the getAllUsers one (because they are part of a bigger flow) and you won't be able to use them separately when you need a different flow.



            Let me know if you need some more help 😉






            share|improve this answer



























              1















              Should I add another saga to listen for the INVITE_USERS_SUCCESS and then call the second action




              Yes, you should. You get the best of Redux-saga when you use only actions to trigger them and, more in general, to make them communicate (it's event-driven development).



              This brings you to write more code but also to develop independent sagas.




              or should I call the getAllUsers() action inside the inviteUsers() action




              I don't recommend you to do that because your inviteUsers saga won't be decoupled from the getAllUsers one (because they are part of a bigger flow) and you won't be able to use them separately when you need a different flow.



              Let me know if you need some more help 😉






              share|improve this answer

























                1












                1








                1








                Should I add another saga to listen for the INVITE_USERS_SUCCESS and then call the second action




                Yes, you should. You get the best of Redux-saga when you use only actions to trigger them and, more in general, to make them communicate (it's event-driven development).



                This brings you to write more code but also to develop independent sagas.




                or should I call the getAllUsers() action inside the inviteUsers() action




                I don't recommend you to do that because your inviteUsers saga won't be decoupled from the getAllUsers one (because they are part of a bigger flow) and you won't be able to use them separately when you need a different flow.



                Let me know if you need some more help 😉






                share|improve this answer














                Should I add another saga to listen for the INVITE_USERS_SUCCESS and then call the second action




                Yes, you should. You get the best of Redux-saga when you use only actions to trigger them and, more in general, to make them communicate (it's event-driven development).



                This brings you to write more code but also to develop independent sagas.




                or should I call the getAllUsers() action inside the inviteUsers() action




                I don't recommend you to do that because your inviteUsers saga won't be decoupled from the getAllUsers one (because they are part of a bigger flow) and you won't be able to use them separately when you need a different flow.



                Let me know if you need some more help 😉







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 26 at 6:14









                NoriSteNoriSte

                1,4601 gold badge10 silver badges9 bronze badges




                1,4601 gold badge10 silver badges9 bronze badges





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55336239%2fcall-actions-sequentially-in-redux-saga-synchronously%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현