Using Ember's App.reset() to kill off any local data

How I resolved an issue with data persisting on the front end

Recently I stumbled across an issue that when my user had logged out of an Ember app and a new user had logged in, sometimes some data was persisting at the front end.

The API was built correctly so the new user couldn't interact with any of it, but it was still messy and a bad experience for the user.

I started looking for a good way to clear out all of this information. I wanted something that ideally I could call once and it would apply to all models.

Happily there is App.reset()

The documentation says it is normally only used in tests but I think this it suits our needs perfectly here.

This is the order things happen in once you call App.reset()

  1. Deactivate existing routes
  2. Destroy all objects in the container
  3. Create a new application container
  4. Re-route to the existing url

Because of the note that it is normally only used in test I would be interested to know if there is a better way I should be doing it?


Recent posts View all

Ruby

Forcing a Rails database column to be not null

How you can force a table column to always have something in it with Rails

Writing Marketing

We've deleted an article's worth of unhelpful words

We've improved several pages across our site by removing words that add no value, and often detract from the article.