mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
added StoragedState
utill
This commit is contained in:
parent
0e482d8d71
commit
1f465fe910
24
packages/app/src/utils/storagedState/index.js
Normal file
24
packages/app/src/utils/storagedState/index.js
Normal file
@ -0,0 +1,24 @@
|
||||
import Dexie from "dexie"
|
||||
|
||||
export default class StoragedState {
|
||||
constructor() {
|
||||
this.db = new Dexie("storaged_states")
|
||||
|
||||
this.db.version(1).stores({
|
||||
states: "id,value",
|
||||
})
|
||||
}
|
||||
|
||||
getState = async (stateKey) => {
|
||||
const data = await this.db.table("states").get(stateKey)
|
||||
|
||||
return data.value
|
||||
}
|
||||
|
||||
setState = async (stateKey, value) => {
|
||||
return await this.db.table("states").put({
|
||||
id: stateKey,
|
||||
value,
|
||||
})
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user