forked from MapComplete/MapComplete
Add a personal, configurable quest
This commit is contained in:
parent
7ec00a3301
commit
b36b103ed3
7 changed files with 55 additions and 54 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue