ember-cli-migrator
ember-cli-migrator copied to clipboard
handling Global calls within an object
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")
});
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.
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.