dimanche 9 août 2015

Why must I lookup store on my simple-auth custom session instead of injecting it as a service?

I have a initializer like this:

import Ember from 'ember';
import Session from 'simple-auth/session';

var SessionWithCurrentUser = Session.extend({
  store: Ember.inject.service(),
  currentUser: function() {
    console.log(this.get('store'));
    console.log(this.store);
    console.log(this.container.lookup('service:store'));
  }.property('secure.access_token')
});

export default {
  name: 'custom-session',
  after: 'ember-data',
  initialize(registry) {
    registry.register('session:withCurrentUser', SessionWithCurrentUser);
  }
};

currentUser gets called on user interaction, long after my app has finished loading. Only the last container lookup gives the store, the other 2 is an object:

{
 _lastData: Object,
 key: "ember_simple_auth:session"
 [..]
}

What's going on? Why can't I inject the store?

Aucun commentaire:

Enregistrer un commentaire