29 lines
579 B
TypeScript
29 lines
579 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import { Storage } from '@ionic/storage';
|
|
|
|
@Injectable()
|
|
export class StorageService {
|
|
|
|
private storage: Storage;
|
|
|
|
constructor() {
|
|
this.storage = StorageService.initStorage();
|
|
}
|
|
|
|
public static initStorage(): Storage {
|
|
return new Storage({});
|
|
}
|
|
|
|
public get(key: string): Promise<{}> {
|
|
return this.storage.get(key);
|
|
}
|
|
|
|
public set(key: string, value: string): Promise<{}> {
|
|
return this.storage.set(key, value);
|
|
}
|
|
|
|
public remove(key: string): Promise<{}> {
|
|
return this.storage.remove(key);
|
|
}
|
|
}
|