Would be awesome to see an example of how to add an observer to ember simple auth's session service data property.
I'm currently stuck on another issue but will be coming back to this soon.
Currently I wrote this in my application/route.js, but I'm blocked on another issue, so I don't know how correct it is. I don't even know if the application route is the best place to put this observer, let alone in the beforeModel hook.
export default Ember.Route.extend({ //adds in login/logout actions
session: Ember.inject.service('session'),
//I also tried putting this code in a model() hook, still no luck.
beforeModel() {
this.get('session').addObserver('data', (sender, key, value, rev) => {
console.log('session data addObserver fired with these arguments:', sender, key, value, rev)
})
},
actions: {
error: function(error, transition) {
console.error('ApplicationRoute error action', arguments)
// substate implementation when returning `true`
return true;
}
}
}).extend(ApplicationRouteMixin)
Note: I'm using an undocumented version of the service.addObserver api, may get bit but I submitted a pull request regarding this: https://github.com/emberjs/ember.js/pull/12768