I have the following case:
...
SN.BaseService = Ember.Object.extend({
action : null,
send: function(action) {
this.set('action', action);
}
});
...
SN.userService = SN.BaseService.create({
login: function() {
if (some_condition) {
this.send("onSuccessfulLogin");
} else {
this.send("onFailedLogin");
}
}
});
...
SN.BaseService.reopen({
onAction: function() {
doSomething();
}.observes('action')
});
SN.BaseService.reopen({
actionChanged: Ember.observer(function() {
doSomething();
}, 'action')
});
My observers (regrdless of the way I set them up – both shown here) never get called i.e. doSomething() is never called.
Observers at object level work fine. It is only when I try to have them at ‘class’ level.
Feedback is very welcome.
Thanks
The problem is that you’re reopening a class after instanciate the object.
It looks like reopening the class does not update each instances.
If I’m not wrong, you can :
Reopening the class before instanciating the userService ( see this jsfiddle )
Reopening the userService directly ( see this jsfiddle ).
There could be some better solutions but I do not know them.