I’m setting up a settings object in my ready
function, and I’m just wondering what the difference is between the two notations:
App.settings
App.get("settings")
Is there some kind of error handling or something available behind get
? What’s the best practice?
Using getters and setters when setting or retrieving properties on Ember objects is super important — it’s how the Ember object model knows to recalculate computed properties, bindings, and observers, which drive a lot of the awesomeness of Ember.
You should definitely read through the Object Model section of the Ember guides if you haven’t already: http://emberjs.com/guides/object-model/classes-and-instances/
Whether or not you expect a property (like your settings object) to participate in bindings or any of that stuff, it’s still a good idea to get in the habit of using the getters & setters.
2 Likes