From efae331f9905c1921ca910d80a7ffaafe529c367 Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Tue, 19 Apr 2022 02:22:32 +0300 Subject: [PATCH] frontend: move value assignment into Store constructor --- frontend/src/stores.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/frontend/src/stores.js b/frontend/src/stores.js index 2f97edb..7a8a59e 100644 --- a/frontend/src/stores.js +++ b/frontend/src/stores.js @@ -2,8 +2,9 @@ import { writable } from "svelte/store"; import gateway, { GatewayEventType } from "./gateway"; class Store { - constructor() { + constructor(value=null) { this._handlers = []; + this.value = value; } subscribe(handler) { @@ -24,9 +25,7 @@ class Store { class ChannelsStore extends Store { constructor() { - super(); - - this.value = gateway.channels || []; + super(gateway.channels || []); gateway.subscribe(GatewayEventType.Ready, ({ channels }) => { this.value = channels; @@ -59,8 +58,7 @@ class ChannelsStore extends Store { class GatewayStatusStore extends Store { constructor() { - super(); - this.value = { open: gateway.open, ready: gateway.authenticated }; + super({ open: gateway.open, ready: gateway.authenticated }); gateway.subscribe(GatewayEventType.Open, () => { this.value.open = true;