BinaryMuse / fluxxor

:hammer_and_wrench: Flux architecture tools for React
http://fluxxor.com/
MIT License
1.69k stars 154 forks source link

Question: asynchronous route transition #134

Open zdila opened 9 years ago

zdila commented 9 years ago

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:

  1. transition is done in the store on SAVE_RECIPE_SUCCESS
  2. transition is done in the JSX component where I check some flag in getStateFromFlux
  3. transition is done in the JSX component where I listen for emitted eg. "save" event
  4. ???

Which should be the preferred way (and why)?

Thanks!

BinaryMuse commented 9 years ago

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.