1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-12 10:14:10 +01:00
bitwarden-browser/src/services/state.service.ts

28 lines
689 B
TypeScript
Raw Normal View History

2018-02-19 18:33:32 +01:00
import { StateService as StateServiceAbstraction } from '../abstractions';
2018-02-12 21:06:18 +01:00
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();
}
}