1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-21 02:33:46 +00:00

state service

This commit is contained in:
Kyle Spearrin
2018-02-12 15:06:18 -05:00
parent 4960fa18c0
commit 56d941a754
4 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import { StateService as StateServiceAbstraction } from '../abstractions/state.service';
export class StateService implements StateServiceAbstraction {
private state: any = {};
get<T>(key: string): Promise<T> {
if (this.state.hasOwnProperty(key)) {
return Promise.resolve(this.state[key]);
}
return Promise.resolve(null);
}
save(key: string, obj: any): Promise<any> {
this.state[key] = obj;
return Promise.resolve();
}
remove(key: string): Promise<any> {
delete this.state[key];
return Promise.resolve();
}
purge(): Promise<any> {
this.state = {};
return Promise.resolve();
}
}