Closed raybooysen closed 5 years ago
Hi @raybooysen,
I don't quite follow. redux-subspace
has a requirement that mapState
return valid state. If you want to remove the state using replaceReducer
then you would need to stop using that subspace first (e.g. unmount the component if you're using react), so before you remove the state.
If it helps, redux-dynostore
(which integrates with redux-subspace
too) has this functionality built in (note: there is a bug with a workaround in the latest version).
I've pretty much done what you suggest. When a user asks to remove a widget, i mark it as inactive which causes the component to become unmounted.
Another epic periodically sweeps up the inactive widgets and removes the reducer. So a simple mark/sweep algorithm
Closing due to inactivity. Happy to reopen if there is more discussion to be had.
Is it a bug, feature request or question?
Bug
Which package(s) does this involve?
redux-subspace
Expected Behavior
replaceReducer should cause subspace to throw
Current Behavior
When using replaceReducer from redux that removes a subspaced reducer, I get an error from redux-suspace at verifyState because the mapState function now returns null.
Context
I have an SPA that allows you to add widgets. As a user adds a widget, I call replaceReducer to add in the new reducer for the widget. When the user closes the widget, I call replaceReducer again to remove the widget.