Use of the at sign ("@")



I’m finally working on an Ember.js project instead of just reading about Ember.js. :smile: Hallelujah!

I’m trying to just move forward instead of dawdling at every new concept, which is my Achilles heel, but I thought I’d ask about the use of the at sign. I have seen it in @each (not that I fully get it) but now I’ve seen @set and @store. I’ve tried finding a reference to this in the Ember.js guides, but I’ve come up empty.





@set and @store are coffeescript…which compiles to this.set and Not really an ember thing (but understandably confusing given the use of @each!)


Interesting!! Thanks very much, Spencer.


There is also an important place where the @ sign is used in Ember in javascript, which is when observing the property of each item in an array of objects.

For instance, if I had an ember object like this:

var User = Ember.Object.extend({
  name: null

var Names = Ember.Object.extend({
  users: [], // an array of User objects, each of which has a 'name' property

  allNames: function(){
    return this.get('users').mapBy('name').join(',');

The value of allNames will update whenever any of its users’ name changes. docs here