From f337e22a645e85715cfe14ef9a9f4229369fe1e0 Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Mon, 7 Jun 2021 01:07:35 +0200 Subject: [PATCH] Makes themes lazy so they can load on nodejs. --- visualization-core/src/Theme.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/visualization-core/src/Theme.ts b/visualization-core/src/Theme.ts index 42e7694..928a74b 100644 --- a/visualization-core/src/Theme.ts +++ b/visualization-core/src/Theme.ts @@ -1,6 +1,19 @@ export class Theme { - public static readonly light = new Theme("light", "light"); - public static readonly dark = new Theme("dark", "dark"); + private static _light: Theme; + public static get light(): Theme { + if (!this._light) { + this._light = new Theme("light", "light"); + } + return this._light; + } + + private static _dark: Theme; + public static get dark(): Theme { + if (!this._dark) { + this._dark = new Theme("dark", "dark"); + } + return this._dark; + } private readonly divElement = document.createElement("div");