Closed RockNHawk closed 3 years ago
Hi @RockNHawk
What was the expected behavior? Dispatch
function is sync but Effects
are async. So Dispatch
will run immediately while Effects
can take more time and can come after all Dispatch
.
@Odonno Yeah, that's the correct behavior, and how could I await the action's effects done ? it seems currently not supported ? so I needs extend it / make a hack ?
Well, I don't think I understand your problem. Are you able to provide a more concrete example?
@Odonno I use ReduxSimple to update/record/display the status information of a process that continues for a long time.
I use Dispatch Action to trigger the Reducer to update the state. When a certain amount is processed, I want to persist the state to the database through Effects, and hope to wait for the Effects processing to complete before continuing the subsequent processing, but currently if I call store.Dispatch(XxxAction) Effects are processed asynchronously, and I want to wait for the effects to be processed before continuing.
From what I understand, you want to mimic a Queue mechanism within the Effect. You could use a standard Queue but if you want to use Rx.NET, which would fit with ReduxSimple, I think you may need to use the Buffer
operator: http://introtorx.com/Content/v1.0.10621.0/13_TimeShiftedSequences.html#Buffer
Does it help?
Thank you for your suggestion. I already have a batch mechanism. I just want to wait for the async effect complete when a "BatchAction" dispatched. Maybe I have to perform persistence operations outside of ReduxSimple, and this problem will be resolved.
Hi, I have tested that if the effect is running in an asynchronous task, the store.Dispatch method will not wait for the effect to complete.
Sometimes I need to wait for all the asynchronous task effects completed, how can I do this ?
Thank you!