Calling App.reset() in ember-cli project


#1

I want to call App.reset() in my ember-cli project when a user logs out, so I did:

import App from 'my-project-prefix/app'

and then

App.reset()

but it seems like the reset function isn’t available on this instance and Im just getting

TypeError: undefined is not a function

#2

I’m curious about this too. I was thinking to use App.reset() to clear data after users log out. But then I noticed that the Ember docs say the method “is typically used only in tests”, which got me worried that maybe I didn’t understand all of the implications for using in the actual app. I never did figure out how to import the app with ember-cli.


#3

< book >

The Ember.Application instance is not available from ‘my-app-name/app’ (the export from that file is a class not an instance).

In 0.0.46 you can access the running app instance at ‘window.MyAppName’, but that is no longer available on master (which will be 0.0.47).

I would definitely suggest just setting window.location to ensure all in memory data is cleared. App.reset() will definitely clear the applications container instance, but it will never clear all possible state. What if you used local closure scoped variables to stash things (wouldn’t be reset with app.reset)? What if your stashing data on the class prototypes (won’t be reset)? What if your application instance itself contains user state information (won’t be reset)?

As you see above App.reset cannot be a silver bullet, because there are many things that we programmers do to stash state all over the place. The only way to guarantee all of those things are reset/cleared is to reset the window.location to your logout page. Your assets should all still be cached, and the page will update quickly, but you can be as certain as possible that you are not leaking information.

< / book >