persist drafts in memory (#155)
Co-authored-by: userAdityaa <aditya.chaudhary1558@gmail.com> Co-committed-by: userAdityaa <aditya.chaudhary1558@gmail.com>
This commit was merged in pull request #155.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
const store = new Map<string, unknown>()
|
||||
|
||||
export class DraftKey<T> {
|
||||
constructor(private key: string) {}
|
||||
|
||||
get(): T | undefined {
|
||||
return store.get(this.key) as T | undefined
|
||||
}
|
||||
|
||||
set(value: T): void {
|
||||
store.set(this.key, value)
|
||||
}
|
||||
|
||||
update(value: Partial<T>): void {
|
||||
this.set({...this.get(), ...value} as T)
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
store.delete(this.key)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user