next-redux-wrapper
next-redux-wrapper copied to clipboard
Add support for complex sagas asynchronously initializing the store state at server-side
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).
@kirill-konshin Would you mind taking a look at this pull request, please?
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