2019-09-12 05:51:59 +02:00
|
|
|
import { I18n } from '../i18n';
|
|
|
|
|
2019-09-07 21:54:44 +02:00
|
|
|
export class ViewController {
|
|
|
|
constructor(state, viewName, defaultState = {}) {
|
|
|
|
// Store the global app state so it's accessible but out of the way.
|
|
|
|
this.appState = state;
|
2019-09-12 05:51:59 +02:00
|
|
|
this.i18n = new I18n(this.appState);
|
2019-09-07 21:54:44 +02:00
|
|
|
|
|
|
|
// Give this view its own state within the appState.
|
|
|
|
if (!this.appState.viewStates.hasOwnProperty(viewName)) {
|
|
|
|
this.appState.viewStates[viewName] = defaultState;
|
|
|
|
}
|
|
|
|
this.state = this.appState.viewStates[viewName];
|
|
|
|
}
|
2019-09-14 06:41:16 +02:00
|
|
|
|
|
|
|
get isLoggedIn () {
|
|
|
|
return this.appState.isLoggedIn;
|
|
|
|
}
|
2019-09-07 21:54:44 +02:00
|
|
|
}
|