More or less working version of advanced conflation

This commit is contained in:
Pieter Vander Vennet 2022-01-06 14:39:42 +01:00
parent 7f99e76b0c
commit 3176a4d665
11 changed files with 634 additions and 524 deletions

View file

@ -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;