Allow init chaining

This commit is contained in:
Bartek Fabiszewski 2019-12-22 20:00:23 +01:00
parent b9db6c0438
commit 5a3d0a802c
6 changed files with 24 additions and 0 deletions

View File

@ -60,10 +60,14 @@ export default class ChartViewModel extends ViewModel {
this.buttonElement = document.querySelector('#altitudes'); this.buttonElement = document.querySelector('#altitudes');
} }
/**
* @return {ChartViewModel}
*/
init() { init() {
this.chartSetup(); this.chartSetup();
this.setObservers(); this.setObservers();
this.bindAll(); this.bindAll();
return this;
} }
chartSetup() { chartSetup() {

View File

@ -34,9 +34,13 @@ export default class ConfigViewModel extends ViewModel {
this.model.onSetInterval = () => this.setAutoReloadInterval(); this.model.onSetInterval = () => this.setAutoReloadInterval();
} }
/**
* @return {ConfigViewModel}
*/
init() { init() {
this.setObservers(); this.setObservers();
this.bindAll(); this.bindAll();
return this;
} }
setObservers() { setObservers() {

View File

@ -39,8 +39,12 @@ export default class MainViewModel extends ViewModel {
this.userMenuEl = document.querySelector('#user-menu'); this.userMenuEl = document.querySelector('#user-menu');
} }
/**
* @return {MainViewModel}
*/
init() { init() {
this.bindAll(); this.bindAll();
return this;
} }
toggleSideMenu() { toggleSideMenu() {

View File

@ -64,9 +64,13 @@ export default class MapViewModel extends ViewModel {
this.api = null; this.api = null;
} }
/**
* @return {MapViewModel}
*/
init() { init() {
this.bindAll(); this.bindAll();
this.setObservers(); this.setObservers();
return this;
} }
/** /**

View File

@ -66,9 +66,13 @@ export default class TrackViewModel extends ViewModel {
this.timerId = 0; this.timerId = 0;
} }
/**
* @return {TrackViewModel}
*/
init() { init() {
this.setObservers(); this.setObservers();
this.bindAll(); this.bindAll();
return this;
} }
setObservers() { setObservers() {

View File

@ -44,6 +44,9 @@ export default class UserViewModel extends ViewModel {
this.state = state; this.state = state;
} }
/**
* @return {UserViewModel}
*/
init() { init() {
this.setObservers(this.state); this.setObservers(this.state);
this.bindAll(); this.bindAll();
@ -62,6 +65,7 @@ export default class UserViewModel extends ViewModel {
} }
}) })
.catch((e) => { uUtils.error(e, `${$._('actionfailure')}\n${e.message}`); }); .catch((e) => { uUtils.error(e, `${$._('actionfailure')}\n${e.message}`); });
return this;
} }
/** /**