fluxxor icon indicating copy to clipboard operation
fluxxor copied to clipboard

Question: asynchronous route transition

Open zdila opened this issue 8 years ago • 1 comments

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!

zdila avatar Sep 10 '15 15:09 zdila

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.

BinaryMuse avatar Sep 17 '15 15:09 BinaryMuse