Created
November 14, 2018 08:59
-
-
Save LironHazan/e3a22a62f249038b778ffc0a234057ab 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'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class LocalStorageWrapperService { | |
constructor() { } | |
private localStorage = localStorage; | |
remove(key) { | |
return this.localStorage.removeItem(key); | |
} | |
get(key) { | |
try { | |
return JSON.parse(this.localStorage.getItem(key)); | |
} catch (e) { | |
return null; | |
} | |
} | |
set(key, value) { | |
return localStorage.setItem(key, JSON.stringify(value)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment