Skip to content

Commit

Permalink
fixed storagetype switching
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsund committed Jul 18, 2016
1 parent 005b2d8 commit ed2cdde
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,27 @@ export default class Storage {
constructor(private $window: angular.IHttpService,
private SatellizerConfig: Config) {
this.memoryStore = {};
this.storageType = SatellizerConfig.storageType;
}

get(key: string): string {
try {
return this.$window[this.storageType].getItem(key);
return this.$window[this.SatellizerConfig.storageType].getItem(key);
} catch (e) {
return this.memoryStore[key];
}
}

set(key: string, value: string): void {
try {
this.$window[this.storageType].setItem(key, value);
this.$window[this.SatellizerConfig.storageType].setItem(key, value);
} catch (e) {
this.memoryStore[key] = value;
}
}

remove(key: string): void {
try {
this.$window[this.storageType].removeItem(key);
this.$window[this.SatellizerConfig.storageType].removeItem(key);
} catch (e) {
delete this.memoryStore[key];
}
Expand Down

0 comments on commit ed2cdde

Please sign in to comment.