New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically starting sagas #23
Comments
While I understand the code splitting requirement. I tend to not agree with starting sagas from inside containers elements. Perhaps, it'd be better to start the dynamic sagas in the same place we update the store. For example, if we load some dynamic module with new reducers and sagas I can imagine function updateAppWithNewModule(module) {
updateStoreWithNewReducer( module.reducer )
runSaga(module.saga)
} FYI, I've already pushed changes in the master branch which include |
Yeah a component was probably a bad example (though I have been curious if Starting the saga at module load time seems like the correct approach; I could see this working well with dynamic routes in react-router. |
technically yes. actually proc has a signature like This is another item on my todo list. Initially, I imagined Another solution I m considering is keeping the generic runSaga( iterator, storeChannel(store) ) With the benefit of being able to connect the Saga to any external channel |
I do like the idea of keeping it generic, would remove the need for things like Is there a common interface that other libraries seem to be using for channel like functionality? closest thing I can think of is Rx.Subject. |
Node duplex streams seems to mimics channel's take/put, but uses 2 independent channels reads/writes. It doesn't also use promises for communication |
FYI. the new v0.4.0 supports |
👍 |
This might have some overlap with with the
runSaga
idea mentioned in #13 (comment).Currently all sagas need to be provided during startup, I am curious if it make sense to have the ability to dynamically start them.
After writing the example below I think the main use case would be larger apps that use code splitting, if you know all your sagas ahead of time its probably simpler to have watchers which fork based on dispatched actions (compatible with time travel).
For example if we only want the
onBoarding
saga to be running while in a specific section of our app it could be started/stopped with a container component:The text was updated successfully, but these errors were encountered: