next-redux-wrapper icon indicating copy to clipboard operation
next-redux-wrapper copied to clipboard

Add support for complex sagas asynchronously initializing the store state at server-side

Open jurca opened this issue 3 years ago • 2 comments

The current usage example does not correctly handle some cases of sagas initializing the store. If saga A is waiting for the result of an asynchronous operation done by saga B, with the result dispatched as a redux action, saga A would never receive the result-carrying action because the END action is dispatched too soon in such a case. (This pattern enables multiple sagas to receive the result of A while having to execute A only once).

This PR handles such use cases by introducing a saga monitor that observes saga activity and reports once every saga has either terminated or is waiting for a redux action (this is an assumption that the saga at hand awaits a user action that would dispatch the expected action, and can be terminated using the END action).

jurca avatar Dec 07 '21 13:12 jurca

@kirill-konshin Would you mind taking a look at this pull request, please?

jurca avatar May 06 '22 11:05 jurca

This solution may resolve this bug https://github.com/kirill-konshin/next-redux-wrapper/issues/515 I'd be glad if I could dispatch End in getStaticProps, and Saga A still receives results from Saga B, Saga C

tannguyenthanhreiq avatar Jun 21 '23 02:06 tannguyenthanhreiq