Skip to content
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

Async transition hooks #26

Closed
mjackson opened this issue Jun 12, 2014 · 3 comments
Closed

Async transition hooks #26

mjackson opened this issue Jun 12, 2014 · 3 comments

Comments

@mjackson
Copy link
Member

The current implementation of Router.dispatch waits for all async transition hooks to resolve before updating the UI. The result of willTransitionTo hooks is also stored off in the currentContext property of routers so that it can be used in components. This is similar Ember's beforeModel and model hook.

In a discussion with @rpflorence this morning, we determined that in the Flux model this method of fetching data from the server doesn't really fit. Components that need model data register to get them from stores as they are mounted. When they are first mounted, if they don't have their data yet, they can show some "loading..." UI. As the store gets the data, the components update. This also has the great benefit of immediately updating the UI in response to user action, which is critical. So we should probably remove the context stuff.

Thus, the primary purpose of transition hooks becomes simply aborting or redirecting the transition. The question is: is there ever a time when we need to asynchronously determine which of these actions to take?

mjackson added a commit that referenced this issue Jun 12, 2014
@mjackson
Copy link
Member Author

What is the use case behind Ember's beforeModel hook?

@mjackson
Copy link
Member Author

Is there ever a time in a transition hook when we don't know immediately if we need to abort or redirect?

@mjackson
Copy link
Member Author

OK, so thinking about this a bit more:

There may be instances where devs want to do something async before transitioning to a component like loading code/data from a server. So let's keep this async for now.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant