Code Monkey home page Code Monkey logo

Comments (7)

abduTas avatar abduTas commented on June 9, 2024

faicing similar issue

from redux-saga.

vinii123 avatar vinii123 commented on June 9, 2024

facing similar issue

from redux-saga.

priyam0074 avatar priyam0074 commented on June 9, 2024

@klis87 , can you help on this? as facing the same issue

from redux-saga.

neurosnap avatar neurosnap commented on June 9, 2024

Greetings! Could you please provide a repo with everything setup so we can better investigate the issue?

from redux-saga.

sandeepahuja-stack avatar sandeepahuja-stack commented on June 9, 2024

Hi @neurosnap
Thanks for quick response
unable to provide the repo

But here are my findings
In server side, We have to dispatch the END

store.dispatch(END as any) 
await store.sagaTask.toPromise()

The middleware provides a special action END. If you dispatch the END
action, then all Sagas blocked on a take Effect will be terminated regardless
of the specified pattern. If the terminated Saga has still some forked tasks
which are still running, it will wait for all the child tasks to terminate
before terminating the Task.

as per my observation, here we can't use take then we are using takeMaybe (https://redux-saga.js.org/docs/api/#takemaybepattern)

const wantsToUseActionPayload = yield takeMaybe('STATE_UPDATE');
console.log(wantsToUseActionPayload) // { type: '@@redux-saga/CHANNEL_END' }

Requirement: We need to consume the response in xyz*, which comes from the api in abc*

from redux-saga.

sandeepahuja-stack avatar sandeepahuja-stack commented on June 9, 2024

Hi @neurosnap, @Andarist

Could anyone please let us know the ways to handle multiple inter dependent saga on SSR?

from redux-saga.

alexya avatar alexya commented on June 9, 2024

My understanding is: (please correct me if misunderstading)
when calling yield put(actionStateUpdate, response); in the generator abc. the action has been called. If you debug into the reducer, the code such as state.data = action.payload should have been executed. But at this time the store/state may not be applied the latest data even if you complete yield takeMaybe('STATE_UPDATE'); or yield take() call.
I don't know why. It may be related to the event loop of the redux-saga. the put call in the saga is a micro task, the state may not be updated until a macro task is called.
So, you can try to add yield delay(100); or call or setTimeout, etc. before yield select(); to init a macro task to ensure the state is updated (queued micro-tasks will be executed)

from redux-saga.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.