Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces the
SafePlugin
type andcreateSafeStore
utility. They opt the user into a more restricted subset of Undux that is more aggressive about preventing cycles in Effects. The way it does this is by statically restricting calls tostore.set
to React components only (this means you can't callstore.set
from Effects).This makes Undux less powerful by imposing a constraint on data flow similar to that imposed by Redux and Flux. It's analogous to a Redux/Flux constraint that prevents calling
dispatcher.dispatch
outside of a React component, or from within a dispatch call. This is not a safety mode that's useful for most users; cycles in Rx streams are rare, and may be better prevented by other means. This PR is a first pass to sketch out what the experience might feel like.Future directions to explore:
.store.set
from Effects, and allow everywhere elsestore.set
calls in generalstore.set
calls in general perform dynamic analysis to warn about cycles in Effects #37Usage