-
Notifications
You must be signed in to change notification settings - Fork 33
[redux-subspace]Being in a subspace, can I dispatch an action to an other one ? #112
Comments
Hi @remy-poirier and thanks for your question. Sorry in advance for typos, I'm on my phone. If I understood correctly, you've got a namespace structure similar to
Where the tabs are direct siblings of each other (in subspace terms, not necessarily in react). What you need is access to the @mpeyper can probably suggest better ways to get access to that Does that make sense to you? If not I'll try to setup a code sandbox later today to demonstrate when I'm on my laptop. Other option could also include using a custom redux middleware that can consume and redirect an action to the correct subspace (if this could be made generic enough it might fit as a new feature for subspace, as we also sometimes struggle with this same problem at IOOF). But I suspect if you could do this, you'd already have a unique enough action name to be able to use a global action. And finally, if you have these kinds of complex interactions between subspaces, you might find yourself constantly fighting against redux-subspace's encapsulation of state and actions. redix-subspace may not be correct solution for your project (but I'm hoping we can figure something out for you). |
Yes, @jpeyper is correct, the only way to achieve this is to us the parent subspace's dispatch function. We recently added a new feature called "Parent Spaces" which is exactly this. Assuming you are using If you are not using If you want to dispatch this from within a thunk or other middleware that provides the |
Closing due to inactivity. Happen to reopen if mre discusison is required. |
Is it a bug, feature request or question?
This is a question:
I am in a subspace, and I want to dispatch an action to an other subspace, without involving a global action.
To contextualize, let's say that my current subspace is
tab1-main
, from this subspace I want to dispatch an action in a new tabtab2-details
, so my action will look like this:type: "tab2-details/actionName, payload: {...}"
, without theglobalAction
flag. Is there any solutions to do so ?I tried to do things like:
In order to get out the current namespace and going into the new one, but it dispatches the action as a
globalAction
and it causes side effect inside my application.I also tried to only dispatch a namespaced action like so:
But obviously it dispatches an action like
tab1-main/tab2-details/actionName
.Your Setup
I hope I am clear and you have a solution
The text was updated successfully, but these errors were encountered: