forked from MapComplete/MapComplete
More or less working version of advanced conflation
This commit is contained in:
parent
7f99e76b0c
commit
3176a4d665
11 changed files with 634 additions and 524 deletions
|
@ -1,5 +1,7 @@
|
|||
import {UIEventSource} from "../UIEventSource";
|
||||
import * as idb from "idb-keyval"
|
||||
import ScriptUtils from "../../scripts/ScriptUtils";
|
||||
import {Utils} from "../../Utils";
|
||||
/**
|
||||
* UIEventsource-wrapper around indexedDB key-value
|
||||
*/
|
||||
|
@ -8,6 +10,9 @@ export class IdbLocalStorage {
|
|||
|
||||
public static Get<T>(key: string, options: { defaultValue?: T }): UIEventSource<T>{
|
||||
const src = new UIEventSource<T>(options.defaultValue, "idb-local-storage:"+key)
|
||||
if(Utils.runningFromConsole){
|
||||
return src;
|
||||
}
|
||||
idb.get(key).then(v => src.setData(v ?? options.defaultValue))
|
||||
src.addCallback(v => idb.set(key, v))
|
||||
return src;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue