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');
}
/**
* @return {ChartViewModel}
*/
init() {
this.chartSetup();
this.setObservers();
this.bindAll();
return this;
}
chartSetup() {

View File

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

View File

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

View File

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

View File

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

View File

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