-
-
Notifications
You must be signed in to change notification settings - Fork 146
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
SubscribeToAction with NavigateTo throws an exception #81
Comments
This looks like the behaviour I would expect. Instead, add an effect that dispatches a GoAction. |
That's very helpful; thanks. I see that this can be resolved by adding either an Effect class or an [EffectMethod] flagged method within my component (which is the option I'll use). Do you think that the ActionAsubscriber Notify method should be protected from this reentrancy problem though? (And thanks for the work on this library.) |
I'll have to think about whether or not to change the loop. The change should happen in an effect. I would put the effect method in with my store, not in the component. They should be kept separate. And if you don't take my advice, at least make it a static method so Fluxor doesn't create an instance of your component. |
I appreciate your thoughts - thank you. |
In a Blazor WASM project, I am trying to handle the navigation to a new page once my HTTP method has completed successfully. My thinking is that I can then choose to remain on the page if I need to handle errors in the API call etc.
Using SubscribeToAction works unless I add a navigation call in the callback.: e.g.
With the navigation call in place, I get
Unhandled exception rendering component: Collection was modified; enumeration operation may not execute.
The exception is thrown by the line in the Notify method of the ActionSubscriber class (line #38):
If I change the previous Select query to persist (i.e. by adding a ToList() call), or change the foreach to
foreach (Action<object> callback in callbacks.ToList())
, the exception is not thrown.It doesn't seem resolvable by unsubscribing from the actions. Is there a way I can resolve this in client code rather than modifying the ActionSubscriber class?
Thanks.
The text was updated successfully, but these errors were encountered: