diff options
Diffstat (limited to 'app/scripts/lib/observable/local-storage.js')
-rw-r--r-- | app/scripts/lib/observable/local-storage.js | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/app/scripts/lib/observable/local-storage.js b/app/scripts/lib/observable/local-storage.js deleted file mode 100644 index 6ed3860f..00000000 --- a/app/scripts/lib/observable/local-storage.js +++ /dev/null @@ -1,37 +0,0 @@ -const ObservableStore = require('./index') - -// -// LocalStorageStore -// -// uses localStorage instead of a cache -// - -class LocalStorageStore extends ObservableStore { - - constructor (opts) { - super() - delete this._state - - this._opts = opts || {} - if (!this._opts.storageKey) { - throw new Error('LocalStorageStore - no "storageKey" specified') - } - this._storageKey = this._opts.storageKey - } - - get() { - try { - return JSON.parse(global.localStorage[this._storageKey]) - } catch (err) { - return undefined - } - } - - _put(newState) { - global.localStorage[this._storageKey] = JSON.stringify(newState) - this.emit('update', newState) - } - -} - -module.exports = LocalStorageStore |