更新
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import type { ICustomStore } from '../../interface/store';
|
||||
|
||||
export default class CustomStore implements ICustomStore {
|
||||
public store: any;
|
||||
|
||||
constructor() {
|
||||
this.store = {};
|
||||
}
|
||||
|
||||
update(key: string, data: any) {
|
||||
this.store[key] = data;
|
||||
}
|
||||
|
||||
getData(key: string) {
|
||||
return this.store[key];
|
||||
}
|
||||
|
||||
reset(keyList: string[] = []) {
|
||||
if (keyList.length === 0) {
|
||||
this.store = {};
|
||||
}
|
||||
this.store = {
|
||||
...this.store,
|
||||
...keyList.reduce((acc, key) => ({ ...acc, [key]: undefined }), {}),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user