fluxxor
fluxxor copied to clipboard
Question: asynchronous route transition
Hello
I am new to React and Flux.
On this line https://github.com/BinaryMuse/fluxxor/blob/master/examples/react-router/app/components/recipe_editor.jsx#L85 when the recipe is edited there is a transition to recipe view.
How to implement it if I have asynchronous object saving? My code is inspired from https://github.com/BinaryMuse/fluxxor/tree/master/examples/async and so the transition should happen after SAVE_RECIPE_SUCCESS
. I see 3 alternatives:
- transition is done in the store on
SAVE_RECIPE_SUCCESS
- transition is done in the JSX component where I check some flag in
getStateFromFlux
- transition is done in the JSX component where I listen for emitted eg. "save" event
- ???
Which should be the preferred way (and why)?
Thanks!
Hi, @zdila,
There are still some differing opinions on this. The "route store" idea is fairly popular, and I'd probably recommend that if you wanted to "stay fluxy" (so basically transition in a special routing store in SAVE_RECIPE_SUCCESS
), though more and more I'm starting to think the complexity in managing it anywhere but inside a callback is just not worth the trade-off (e.g. maybe we should just redirect in a callback). Have you seen the discussion at #132? It's related to this topic.