1 import {kebabToCamel} from "../services/text";
4 export class Settings {
6 constructor(initialSettings) {
8 this.changeListeners = {};
9 this.merge(initialSettings);
13 key = this.normaliseKey(key);
14 this.settingMap[key] = value;
15 for (const listener of (this.changeListeners[key] || [])) {
21 return this.settingMap[this.normaliseKey(key)] || null;
25 for (const [key, value] of Object.entries(settings)) {
30 onChange(key, callback) {
31 key = this.normaliseKey(key);
32 const listeners = this.changeListeners[this.normaliseKey(key)] || [];
33 listeners.push(callback);
34 this.changeListeners[this.normaliseKey(key)] = listeners;
38 return kebabToCamel(key.replace('md-', ''));