title: Refresh all data other than session data when context changes
body: <p>I'm writing a small sample application which will display some information to a user in dashboards and tables.</p>
  
  <p>The application is being written using <code>ember-cli</code> version 0.0.37. and <code>ember.js</code> version 1.5.1.</p>
  
  <p>I am using <code>ember-simple-auth</code> and <code>ember-simple-auth-oauth2</code> for authentication, with a custom authenticator and authroizer to inject the client_id, client_secret and access_token into the requests where appropriate (I am fully aware that the client secret shouldn't be in a front end application, but this is a sample application for internal consumption only and not the subject of my question).</p>
  
  <p>The custom authorizer also injects an o parameter into the requests, the value of which is an organisation id.  The API returning data uses both the access_token and the o parameter to return data pertaining to a particular organisation.  The organisation id is stored in the session.</p>
  
  <p>So once I've browsed around for one organisation, I've got a dropdown component which allows me to choose another organisation.  At present, this calls an action on the ApplicationRoute which updates the value in the session, and clears the store of all models that are not account or organisation, as these are used at the application level.</p>
  
  <p>Code:</p>
  
  <pre><code>setSessionOrganisation: function(organisation_id) {
      var self = this;
  
      /**
       * Check if its the same organisation
       */
      if (this.get('session.organisation_id') == organisation_id) {
          return;
      }
  
      /**
       * Get the organisation for the id provided
       */
      this.store.find('organisation', organisation_id).then(
          function(org) {
  
              /**
               * Update the session details
               */
              self.set('session.organisation_id', org.get('id'));
              self.set('session.organisation_name', org.get('name'));
  
              /**
               * Get all types
               */
              var store = self.container.lookup('store:main');
              var types = [];
              var typeMaps = store.typeMaps;
              $.each(typeMaps, function(key) {
                  if (typeMaps.hasOwnProperty(key)) {
                      var type = typeMaps[key].type.typeKey;
                      if (type != 'account' &amp;&amp; type != 'organisation'){
                          types.push(typeMaps[key].type.typeKey);
                      }
                  }
              });
  
              /**
               * Clear data for types
               */
              for (var i = 0; i &lt; types.length; i++) {
                  store.unloadAll(types[i]);
              };
          });
  }
  </code></pre>
  
  <p>I feel the code above is a bit hackish, but I've not found another way to return the model types currently in the store.</p>
  
  <p>When this action is called, and the data has been flushed, I would like to then refresh/reload the current route.  Some of the routes will be dynamic, and using the object ids as the dynamic segment.  These routes will need to redirect to their list routes.  Other routes will carry on lazily loading data when they are navigated to.</p>
  
  <p>So my questions are:</p>
  
  <ul>
  <li>Is there a better way to clear the store data than I have done above?</li>
  <li>How can I trigger a route reload?</li>
  <li>How can I redirect to the parent route if in a route with a dynamic segment?</li>
  </ul>
  
  <p>As a bonus question, are there any dangers in unloading all the data for views/routes that are presently not being displayed?</p>
  
  <p>Thanks!</p>