Moved common and utils services to their own service providers

This commit is contained in:
Alejandro Celaya
2018-12-18 20:19:22 +01:00
parent 4b1f5e9f4c
commit eec79043cc
13 changed files with 83 additions and 45 deletions

View File

@@ -0,0 +1,16 @@
const PREFIX = 'shlink';
const buildPath = (path) => `${PREFIX}.${path}`;
export default class Storage {
constructor(localStorage) {
this.localStorage = localStorage;
}
get = (key) => {
const item = this.localStorage.getItem(buildPath(key));
return item ? JSON.parse(item) : undefined;
};
set = (key, value) => this.localStorage.setItem(buildPath(key), JSON.stringify(value));
}