mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
Split jslib into multiple modules (#363)
* Split jslib into multiple modules
This commit is contained in:
27
common/src/services/state.service.ts
Normal file
27
common/src/services/state.service.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user