-
Notifications
You must be signed in to change notification settings - Fork 33
Limited compatibility with redux-sagas #18
Comments
Hi Michael, I have added a simple redux-saga example with namespacing feature. |
Hey Amit, Thanks for contributing! I think the files I want to be concentrating on are the component sagas and the app sagas, right? Firstly, when I'm looking at this, I'm keeping subspace's key concepts in mind, so having the parent control the bounds of the subspace and the child being unaware of the parent Ideally, the interface when integrating the component sagas would look something like:
where the component exports unmodified sagas and subspace takes care of the rest. From my understanding (which is admittedly limited on sagas), the issue here is that we don't have a way of intercepting the actions before the Because of this, it may be necessary to bleed some of the subspace logic into the component. When doing so though, it should be in a way that the parent (app in this case) is still in control and so that the component has to know as little about subspace's implementation as possible. For example, if the app sagas did not pass through a namespace, you example would not work. If the component sagas looked something like:
where Another feature to be wary of is global actions which should not be namespaced when taking or putting, so providing a function that can take care of all of these intricacies will help a lot for component reuse. Thoughts? |
Since your comment sparked my interest in sagas again, I've been looking at the documentation a bit more closely and I noticed a different Technically it runs them outside of redux, but I'm wondering if we can provide a saga wrapper that is run inside redux, and passes the filtered actions into the Does this sound crazy? |
So following the external I think there is some real potential in this solution. |
Looks good 👍 |
I thought I should probably explain the main parts of the spike. Firstly, we need to wrap the top-most parent's sagas with
This injects the redux store into that saga's context (i.e. any saga it spawns will have access to it's context). We need to do this to get access to the Then when combining the component's saga's into the app's sagas we need to wrap them in a subspace (similar to wrapping a component when mounting it):
This is where the magic happens. The It also replaces the store in the context with a subspaced store, so theoretically (I have to try this), it should work with nested subspaced sagas (i.e. if the component's sagas included a I've also been thinking about how to actually release these helpers. They have a explicit dependency on My feeling is that I would actually like to split the library into three parts:
This way, redux-subspace is no longer tied specifically to React and can be used with any project using redux. Note: I have changed the interfaces on some of the Higher-Order-Blah parts of the API. They will still function the same as they do now, but they are more composable, which is nice. Thoughts on any of the above? @vivian-farrell, I'd be interested in your take on the proposed library split. |
@mpeyper |
Sagas support has now been added in 2.0.1-alpha. Please try it out and let us know if there are any issues. I'll close this once the version is out of pre-release. |
V2 has been released now so I'm closing this issue. |
As identified in #8, there is only partial compatibility with redux-sagas.
There appear to be no issues until the namespacing feature is used. The actions being dispatched by sagas are not passing through our wrapper and the namespaces are not being applied so the reducers are discarding them.
I have taken a look at the problem myself, but without much exposure to sagas before, I'm struggling to find a solution so any help would be much appreciated.
The text was updated successfully, but these errors were encountered: