-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[WIP] Make model hooks run in parallel #12415
Conversation
Making the model hook sync and changing the return value of modelFor definitely seem like a breaking changes, am I missing something? Do these public API changes correspond with an RFC? |
I found the description of this issue misleading. "Synchronous" in most of javascript means "returning a value immediately", which is not the case here. Perhaps it would be better to say "make model hooks run in parallel". |
@rwjblue -- "I am laying out the required changes directly in the source so we can plan how to hook into the necessary parts of Ember from that addon." I'm using these two PRs basically as glorified diffs so a discussion may be had regarding what hooks are needed in Ember to enable an addon to achieve this same result. |
Random thoughts:
|
We've trained an army of Ember developers to expect that routes and models resolve in a particular manner but it turns out that it's a tremendous performance anti-pattern. We have examples in our application where an approach like this would reduce page load time by 500ms or more and also allows for a much better incremental loading behavior. With that much of a win it's not optional for us to skip this as an optimization. (@nickiaconis is working on posting a side-by-side demo.) Further, our performance wins imply that this approach would be just as beneficial for other members of the Ember community. If it weren't for the existing API I feel like everybody adopting this behavior would be a no-brainer. That being said, we likely can't drop support for our present pattern for approximately two years. Ember's options for landing behavior like this, ranked in order of my preference for our application:
Let's skip talking about exact implementation for a moment (e.g. |
It is 100% clear to me that this needs to be an RFC, for precisely the reasons you highlight. If you need close coordination with Ember, and if we need a coherent story for the community, then we need to do it right and have a coherent plan. I am totally on board with this feature and have had several discussions in the past with other core team members who also want this feature. There will be no barrier to getting it done, it just needs to be fully designed in an RFC. |
Closing this PR in favor of the discussion and progress in emberjs/rfcs#97 |
Opening for discussion on how to support running model hooks in parallel. From an IRL discussion with @wycats and @nathanhammond, this should be built as an addon, so that apps must explicitly opt into the functionality and related consequences. I am laying out the required changes directly in the source so we can plan how to hook into the necessary parts of Ember from that addon.
The big consequence of making model hooks run in parallel is that
modelFor
must return a promise. Here are the changes that make that happen.Parallel model hooks require changes to router.js as well: tildeio/router.js#171