Can't always (but sometimes) unloadAll from a route's activate hook


When the user of my application clicks logout, I send them to a logout route. The “activate” method of the logout route sends a request to the server, clears session data using multiple unloadAll calls, and sets a timeout to redirect to the index route. The “deactivate” method clears the timeout, in case the user navigated away early. The logout route displays an appropriate message.

Sometimes the logout route fails. The “activate” hook is called, but never finishes. The “loading” route is displayed. No exceptions are shown in the console, but I used devtools to find “Attempted to handle event unloadRecord on … while in state root.loading.”

Is it true, I cannot call unloadAll from inside the activate hook? Why is this?

Thanks : ) Matt

Flush the contents of the "Store" object

Kind of makes sense as the data may be changing during the loading state, so it would be difficult to unloadAll for a type while (for example) a RESTAdapter request were still pending that could result in new items of the type.

Better to move the unloadAll stuff into an action handler, e.g. on the application route, and then transition to the logout message.

Would be nice to see this documented here: