Skip to content

Instantly share code, notes, and snippets.

@Bilkiss
Last active December 19, 2021 13:44
Show Gist options
  • Save Bilkiss/fc84efbd332d8450549daec74baa427c to your computer and use it in GitHub Desktop.
Save Bilkiss/fc84efbd332d8450549daec74baa427c to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class StorageService {
private storeDataSubjects: Map<string, BehaviorSubject<any>> = new Map();
constructor() { }
set(key: string, value: any): void {
let val = JSON.stringify(value);
localStorage.setItem(key, val);
}
get(key: string): any {
return JSON.parse(localStorage.getItem(key)) ;
}
remove(key: string): void {
localStorage.removeItem(key);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment