app state destroys itself when the route changes

This commit is contained in:
Joe Fleming 2014-09-30 11:30:42 -07:00
parent 3077ace5b4
commit 82870ec4a4

View file

@ -1,14 +1,16 @@
define(function (require) {
var _ = require('lodash');
return function AppStateProvider(Private) {
return function AppStateProvider(Private, $rootScope) {
var State = Private(require('components/state_management/state'));
_(AppState).inherits(State);
function AppState(defaults) {
AppState.Super.call(this, '_a', defaults);
}
// When we have a route change, destroy the app state
$rootScope.$on('$routeChangeStart', _.bindKey(this, 'destroy'));
}
return AppState;
};