@croatialu/async-storage
v0.0.4
Published
<p align="center"> <img src="https://img.shields.io/github/workflow/status/CroatiaParanoia/async-storage/CI.svg?sanitize=true" alt="Build Status"> <!-- <img src="https://img.shields.io/codecov/c/github/CroatiaParanoia/async-storage/master.svg?sanitize
Downloads
7
Readme
async-storage
An asynchronous storage tool
Useage
basic
remote, API server, redis, or db, etc...,
import { createAsyncStorage } from '@croatialu/async-storage'
interface RemoteStorageTypes {
user: { name: string, age: string, gender: 'male' | 'female' }
}
const RemoteStorage = createAsyncStorage({
async set(key, value){
return apiServer.post('/api/user-storage', { key, value })
}
async get(key){
return apiServer.get('/api/user-storage')
}
})
const remoteStorage = new RemoteStorage<RemoteStorageTypes>()
remoteStorage.set('user', { name: 'croatia', age: 23, gender: 'male' })
remoteStorage.set('user', (oldUser) => {
return { ...oldUser, age: 24 }
})