Add a personal, configurable quest

This commit is contained in:
Pieter Vander Vennet 2020-07-31 17:11:44 +02:00
parent 7ec00a3301
commit b36b103ed3
7 changed files with 55 additions and 54 deletions

View file

@ -1,24 +1,22 @@
import {UIEventSource} from "../UI/UIEventSource";
import {UIElement} from "../UI/UIElement";
export class LocalStorageSource {
static Get(key: string, defaultValue: string = undefined): UIEventSource<string> {
if (UIElement.runningFromConsole) {
try {
// ignore when running from the console
const saved = localStorage.getItem(key);
const source = new UIEventSource<string>(saved ?? defaultValue);
source.addCallback((data) => {
localStorage.setItem(key, data);
console.log("Wriging ", key, data)
});
return source;
} catch (e) {
return new UIEventSource<string>(defaultValue);
}
const saved = localStorage.getItem(key);
const source = new UIEventSource<string>(saved ?? defaultValue);
source.addCallback((data) => {
localStorage.setItem(key, data);
console.log("Wriging ", key, data)
});
return source;
}
}
}