From 5a3d0a802c212edfcf0cf9788930b33ead30e1e3 Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Sun, 22 Dec 2019 20:00:23 +0100 Subject: [PATCH] Allow init chaining --- js/src/chartviewmodel.js | 4 ++++ js/src/configviewmodel.js | 4 ++++ js/src/mainviewmodel.js | 4 ++++ js/src/mapviewmodel.js | 4 ++++ js/src/trackviewmodel.js | 4 ++++ js/src/userviewmodel.js | 4 ++++ 6 files changed, 24 insertions(+) diff --git a/js/src/chartviewmodel.js b/js/src/chartviewmodel.js index 289a40b..451e03a 100644 --- a/js/src/chartviewmodel.js +++ b/js/src/chartviewmodel.js @@ -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() { diff --git a/js/src/configviewmodel.js b/js/src/configviewmodel.js index ee3a3ad..60111cf 100644 --- a/js/src/configviewmodel.js +++ b/js/src/configviewmodel.js @@ -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() { diff --git a/js/src/mainviewmodel.js b/js/src/mainviewmodel.js index 645fcf5..a75eca9 100644 --- a/js/src/mainviewmodel.js +++ b/js/src/mainviewmodel.js @@ -39,8 +39,12 @@ export default class MainViewModel extends ViewModel { this.userMenuEl = document.querySelector('#user-menu'); } + /** + * @return {MainViewModel} + */ init() { this.bindAll(); + return this; } toggleSideMenu() { diff --git a/js/src/mapviewmodel.js b/js/src/mapviewmodel.js index 6828c84..a8cd613 100644 --- a/js/src/mapviewmodel.js +++ b/js/src/mapviewmodel.js @@ -64,9 +64,13 @@ export default class MapViewModel extends ViewModel { this.api = null; } + /** + * @return {MapViewModel} + */ init() { this.bindAll(); this.setObservers(); + return this; } /** diff --git a/js/src/trackviewmodel.js b/js/src/trackviewmodel.js index 31ba148..b8d15ff 100644 --- a/js/src/trackviewmodel.js +++ b/js/src/trackviewmodel.js @@ -66,9 +66,13 @@ export default class TrackViewModel extends ViewModel { this.timerId = 0; } + /** + * @return {TrackViewModel} + */ init() { this.setObservers(); this.bindAll(); + return this; } setObservers() { diff --git a/js/src/userviewmodel.js b/js/src/userviewmodel.js index e5de8ea..c8b9519 100644 --- a/js/src/userviewmodel.js +++ b/js/src/userviewmodel.js @@ -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; } /**