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

handling Global calls within an object #49

Open
koryteg opened this issue Mar 8, 2015 · 2 comments
Open

handling Global calls within an object #49

koryteg opened this issue Mar 8, 2015 · 2 comments

Comments

@koryteg
Copy link

koryteg commented Mar 8, 2015

looks like as of right now the migrator just parses the JS for any declaration of the global namespace declared and removes it.

if it could change the global declaration to its correct instance call.
ie:

MyApp.ApplicationController = Ember.ObjectController.extend({
  updateCurrentPath: (function() {
    MyApp.set("currentPath", this.get("currentPath"));
  }).observes("currentPath")
});

should get changed to :

ApplicationController = Ember.ObjectController.extend({
  updateCurrentPath: (function() {
    this.container.lookup('application:main').set("currentPath", this.get("currentPath"));
  }).observes("currentPath")
});
@fivetanley
Copy link
Owner

I think the path moving forward for this is moving stuff to the application controller and using needs... might be possible to do automatically too. Just cuz container is private api and likely to break, would be great to not encourage people to use private api.

@koryteg
Copy link
Author

koryteg commented Mar 16, 2015

right that sounds like the correct approach, I am still learning some of the best practices of ember. looks like the new service objects feature might be a good option as well.

an easy quick short term solution might be to add a step in the usage docs to remind people that everywhere they are using globals inside a class will need to be refactored.

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

2 participants