mercredi 7 janvier 2015

Forcing the router to pause until current user is loaded

I'm using Ember Simple auth, and I'm using an initializer to set the current authenticated user as a property on my session:



Session.reopen({
setCurrentUser: function() {
var id = this.get("user_id");
var self = this;

if (!Ember.isEmpty(id)) {
return container.lookup("store:main").find("user", id).then(function(user) {
self.set("currentUser", user);
});
}
}.observes("user_id")
});


Is it possible to force the router to wait until currentUser has been set before ending the initial app transition? I want certain components to be able to access session.currentUser as soon as the app boots up.


Aucun commentaire:

Enregistrer un commentaire