UNPKG

lazy-widgets

Version:

Typescript retained mode GUI for the HTML canvas API

42 lines 1.31 kB
import { BaseTheme } from './BaseTheme.js'; /** * Provides styling for {@link Widget | Widgets}. * * @category Theme */ export class Theme extends BaseTheme { constructor(properties, fallbackTheme) { super(properties, fallbackTheme); this.subscribers = new Set(); } get fallbackTheme() { return super.fallbackTheme; } set fallbackTheme(newTheme) { super.fallbackTheme = newTheme; } onThemeUpdated(property = null) { // Notify all subscribers for (const listener of this.subscribers) { listener(property); } } /** * Subscribe to this theme. When a change occurs in the theme, the passed * listener callback will be called. The argument used for the callback will * be null if the theme's fallback has changed and therefore all properties * are to be assumed as changed, else, the argument will be a string * containing the name of the theme property that changed. */ subscribe(listener) { this.subscribers.add(listener); } /** * Unsubscribe from this theme; removes the listener callback from the list * of subscribers. */ unsubscribe(listener) { this.subscribers.delete(listener); } } //# sourceMappingURL=Theme.js.map