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

Consider making currentModel in Ember.Route public #11760

Closed
SaladFork opened this issue Jul 15, 2015 · 4 comments
Closed

Consider making currentModel in Ember.Route public #11760

SaladFork opened this issue Jul 15, 2015 · 4 comments

Comments

@SaladFork
Copy link
Contributor

This private API is one I use frequently in my applications to programmatically get the current route's model. It is mostly a convenience for this.modelFor(this.routeName)¹. This is especially useful for writing re-usable route code which needs to get at the current route's model.

¹ Though routeName is private, see #11759

@davidgoli
Copy link

👍 super useful - when I see in a route this.modelFor('a.route.name') I always have to double-check to see if it's the current route's name or not. This would eliminate that source of confusion, especially it seems the best practice is to have the route handle actions by manipulating its own model, and (ideally) not some other route's model.

@rwjblue
Copy link
Member

rwjblue commented Jul 17, 2015

Discussed this at the core team meeting this afternoon, and decided that we'd like to keep this as private. As you mentioned this.modelFor(this.routeName) (I just chimed in on #11759 that we should make this.routeName public) is a good way to do this with public API's. You can also use this.get('controller.model'). Both of these suggestions shoudl remove the ambiguity with this.modelFor('a.b.c') that @davidgoli mentioned..

@rwjblue
Copy link
Member

rwjblue commented Jul 17, 2015

Thanks for opening the issue for discussion, I'm going to close now that we have discussed and decided to keep private.

@rwjblue rwjblue closed this as completed Jul 17, 2015
@davidgoli
Copy link

Sounds good, I will then create an alias in ApplicationRoute that's just currentModel: function () { return this.modelFor(this.routeName); } because that is immensely useful and a shame it's getting overlooked. But we shall carry on!

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

3 participants