UNPKG

@lomray/react-mobx-manager

Version:
3 lines (2 loc) 625 B
class t{globalKey;storage;constructor({storage:t,globalKey:e}){this.storage=t,this.globalKey=e??"stores"}async get(){try{return JSON.parse(await this.storage.getItem(this.globalKey)||"{}")}catch(t){return console.error("Failed to get item from async storage:",t),{}}}async flush(){try{return await this.storage.removeItem(this.globalKey)}catch(t){console.error("Failed to flush async storage key:",t)}}async set(t){try{return await this.storage.setItem(this.globalKey,JSON.stringify(t||"{}"))}catch(t){console.error("Failed to set value to async storage:",t)}}}export{t as default}; //# sourceMappingURL=async-storage.js.map