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

Decouple controller lookup from URL generation. #14980

Merged
merged 1 commit into from
Mar 4, 2017

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Mar 3, 2017

Currently, calling emberRouter.routerMicrolib.generate('somethign'); will force both something route and something controller to be looked up. We do this so that we can properly handle any query params within that route/controller pair.

The ember-routing-router-service work is adding a urlFor method, that will ultimately allow users to generate urls without forcing the controllers to be looked up eagerly. Unfortunately, at the moment the eager controller lookup is completely entangled with the getHandler function that we provide to the router microlib.

This commit removes the forced eager evaluation of _qp on a route within the getHandler function, while still supporting the current implementation of {{link-to}} (which still utilizes the eager _qp evaluation to generate href's).

Some work is needed in ember-engines to support this PR, which I am working on now...

I did emberobserver.com searches for the following:

  • route-meta - Only one real usage outside of Ember itself (ember-engines).
  • _populateQPMeta - Two usages (ember-engines and ember-cli-bundle-loader).

TODO:

Currently, calling `emberRouter.routerMicrolib.generate('somethign');` will
force both `something` route and `something` controller to be looked up.
We do this so that we can properly handle any query params within that
route/controller pair.

The `ember-routing-router-service` work is adding a `urlFor` method, that
will ultimately allow users to generate urls without forcing the controllers
to be looked up eagerly. Unfortunately, at the moment the eager controller
lookup is completely entangled with the `getHandler` function that we provide
to the router microlib.

This commit removes the forced eager evaluation of `_qp` on a route within the
`getHandler` function, while still supporting the current implementation of
`{{link-to}}` (which still utilizes the eager `_qp` evaluation to generate
`href`'s).
@@ -609,7 +609,6 @@ const EmberRouter = EmberObject.extend(Evented, {
}

handler._setRouteName(routeName);
handler._populateQPMeta();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you've removed this to enable lazy evaluating of qp meta, but where is this lazy evaluation happening? How is this backwards compatible?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scalvert - Great question, general reasons below:

  • if you look at _populateQPMeta()'s definition, all it does is eagerly this.get('_qp') and save it off into the bucket cache, however nothing ever looks it up!!!
  • Things like Ember.Router#_prepareQueryParams (used by {{link-to, transitionTo, etc) are calling route._getQPMeta() which does return route.get('_qp') (I'm guessing that at some point it was returning from the bucket cache, but it does not do this any longer). This still works (regardless of _populateQPMeta() being called first).

@chadhietala
Copy link
Contributor

Good investigative work on this @rwjblue!

@chadhietala chadhietala merged commit e994e80 into emberjs:master Mar 4, 2017
@rwjblue rwjblue deleted the decouple-controller-lookup branch March 5, 2017 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants