forked from MapComplete/MapComplete
		
	Performance: don't clone objects when saving them to the IDB
This commit is contained in:
		
							parent
							
								
									139b60756b
								
							
						
					
					
						commit
						6c6f988f3c
					
				
					 1 changed files with 6 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -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()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue