Performance: don't clone objects when saving them to the IDB

This commit is contained in:
Pieter Vander Vennet 2024-08-09 14:41:26 +02:00
parent d0f3fa08b4
commit f4c73c92e3

View file

@ -10,7 +10,7 @@ export class IdbLocalStorage {
public static Get<T>(
key: string,
options?: { defaultValue?: T; whenLoaded?: (t: T | null) => void }
options?: { defaultValue?: T; whenLoaded?: (t: T | null) => void },
): UIEventSource<T> {
if (IdbLocalStorage._sourceCache[key] !== undefined) {
return IdbLocalStorage._sourceCache[key]
@ -39,11 +39,14 @@ export class IdbLocalStorage {
}
public static SetDirectly(key: string, value: any): Promise<void> {
const copy = Utils.Clone(value)
return idb.set(key, copy)
return idb.set(key, value)
}
static GetDirectly(key: string): Promise<any> {
return idb.get(key)
}
static clearAll() {
return idb.clear()
}
}