First version which caches changesets if not uploaded

This commit is contained in:
Pieter Vander Vennet 2021-07-10 15:52:52 +02:00
parent d72dbc21df
commit 6732c12a0c
7 changed files with 84 additions and 41 deletions

View file

@ -4,6 +4,22 @@ import {UIEventSource} from "../UIEventSource";
* UIEventsource-wrapper around localStorage
*/
export class LocalStorageSource {
static GetParsed(key: string, defaultValue : any){
return LocalStorageSource.Get(key).map(
str => {
if(str === undefined){
return defaultValue
}
try{
return JSON.parse(str)
}catch{
return defaultValue
}
}, [],
value => JSON.stringify(value)
)
}
static Get(key: string, defaultValue: string = undefined): UIEventSource<string> {
try {