File: /var/www/vhost/disk-apps/pwa.sports-crowd.com/src/app/services/storage.service.ts
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage-angular';
@Injectable({
providedIn: 'root'
})
export class StorageService {
private _storage: Storage | null = null;
constructor(private storage: Storage) {
this.init();
}
async init() {
// If using, define drivers here: await this.storage.defineDriver(/*...*/);
const storage = await this.storage.create();
this._storage = storage;
}
// Create and expose methods that users of this service can
// call, for example:
set(key: string, value: any) {
this._storage?.set(key, value);
}
get(key){
return this._storage?.get(key);
}
// elimna un key del storage
async remove(key){
await this._storage.remove(key);
}
// elimina todo el localstorage
async clear(){
await this._storage.clear();
}
}