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

Don't advertize deprecated initializer functionality #462

Closed
zeppelin opened this issue Mar 13, 2015 · 6 comments
Closed

Don't advertize deprecated initializer functionality #462

zeppelin opened this issue Mar 13, 2015 · 6 comments
Milestone

Comments

@zeppelin
Copy link
Member

Since the Ember container/registry separation, calling lookup in initializers is deprecated and available only for backwards-compatibility, yet it's usage is still advertised in the ApplicationRouteMixin's documentation. It would be good if an alternative solutuion was offered instead.

@vire
Copy link

vire commented Mar 14, 2015

@zeppelin could you submit a PR with an alternative solution? I'm very interested in this concept because I've used a lot of container.lookup in initializers.

Thanks!

@zeppelin
Copy link
Member Author

@vire absolutely, but it'd be even better if we could get expert advice from @dgeb, he did the container/registry refactor.

@marcoow
Copy link
Member

marcoow commented Apr 22, 2015

It would probably be god to use Ember's new service injection API.

@dgeb: would that be the suggested way of making the session available, e.g.

//app/components/my-component.js
export default Ember.Component.extend({
  session: authManager: Ember.inject.service('session')
})

?

@dgeb
Copy link

dgeb commented Apr 22, 2015

If you want to make a service available on a particular component, then you can definitely use the service injection API.

Note that:

//app/components/my-component.js
export default Ember.Component.extend({
  session: Ember.inject.service('session')
});

Is equivalent to:

//app/components/my-component.js
export default Ember.Component.extend({
  session: Ember.inject.service()
});

This is because the property is named the same as the service (session).

You can certainly also call application.inject() from an initializer to make a service available more broadly (say, to all routes).

I've opened an RFC to steer the registry / container / initializer work in the direction I'd like to take it: emberjs/rfcs#46

@marcoow marcoow added this to the 0.8.0 milestone Apr 22, 2015
@marcoow
Copy link
Member

marcoow commented Apr 22, 2015

Thanks @dgeb! Ember Simple Auth now uses the application's register and inject methods rather than the container's register and injection.

@dgeb
Copy link

dgeb commented Apr 22, 2015

Great - glad to help!

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

No branches or pull requests

4 participants