Observer syntax


#1

What’s the difference between this:

propertyB: function() { 
   ... 
}.observes('propertyA')

this:

propertyB: Ember.observer(function() { 
   ... 
}).observes('propertyA')

and this:

propertyB: Ember.observer('propertyA', function() { 
   ... 
})

#2

Your first and last example are the same. I’ve never seen your middle example if it works it probably also does the same thing.

As to which one to use, I’ve noticed there seems to be a push away from the native extention stuff so number 3 Ember.observer is probably the best way to go.

I’ve also taken to doing var observer = Ember.observer at the beginning of my class file after I read the dockyard style guide.


#3

I rather use the 3rd one too but I wasn’t sure if the other ones did something different.

Thank you for the guide :smiley: