vendredi 16 juin 2017

Ember.js Service objects recreated on route transition

As I understand from the documentation a Service is basically a singleton object used to provide services to other objects through the application lifecycle. I have a user management service which I use to save an authentication token after the user logs in using the route /users/login. But transitioning to another route (/composer for instance) causes the service instance to be recreated and hence it loses all the stored data. Doesn't this contradict the fact that it should live as long as the application does or do I have a wrong of idea this whole lifecycle thingy?

I'm injecting the service in all my routes as below:

authenticationService: Ember.inject.service('authentication-service'),

The service itself is only a set of getters and setters.

I'm not looking for suggestions on using some other means of persistence such as IndexedDB; I'm willing to understand how this thing actually works so any explanation is appreciated.




Aucun commentaire:

Enregistrer un commentaire