0
votes

I have this setup right now:

App.Workspace = Em.Object.extend({
  users: null,
  usersChanged: Em.observer('users',function() {
    console.log('Users Updated!');
  }),
  ...
  initListeners: function() {
    var self = this;
    someObject.on('someEvent', function() {
      ...
      console.log('before set');
      self.set('users', self.store.all('users'));
    });
  }
});

I only get the output "before set", but not "Users updated!"

What am I missing?

1
Store returns a promise, see stackoverflow.com/questions/30685344/… for a solution.kunerd
emberjs docs about all(): "This method returns a filtered array"K..
Sorry, I missed that. I tried a similar thing and it worked. Can you provide a JSBin for your problem?kunerd

1 Answers

1
votes

1) Use

Em.observer('users.[]',function() {...});

to observe RecordArray. Look at jsbin demonstration for you. http://jsbin.com/noxijuloqi/edit?html,js,output

2) Make sure you've injected store into your Object properly, so self.store is not undefined.

3) Also you should correct typo

self.store.all('user');

instead

self.store.all('users');