Last active
December 19, 2021 13:44
-
-
Save Bilkiss/fc84efbd332d8450549daec74baa427c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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