Skip to content

Commit

Permalink
fix: propagate change of value to all services and decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielKucal committed Feb 17, 2018
1 parent abe709b commit 4e5486b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/decorator/cache-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class CacheItem implements CacheItemInterface {
this.proxy = null;
}

protected propagateChange(value: any, source) {
public propagateChange(value: any, source) {
if (isEqual(value, this.readValue())) return;
this.utilities.forEach(entry => {
const utility = entry.utility;
Expand Down
1 change: 1 addition & 0 deletions src/utility/webstorage.utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class WebStorageUtility {
if (cacheItem) {
debug.log(`updating following CacheItem from ${this.constructor.name}:`, cacheItem);
cacheItem.resetProxy();
cacheItem.propagateChange(value, this);
}
} catch (error) {
console.warn(`[ngx-store] ${this.getStorageName()}: following error occurred while trying to save ${key} =`, value);
Expand Down
2 changes: 1 addition & 1 deletion tests/decorator/webstorage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('Decorators', () => {
sessionStorageService.set('sessionStorageVariable', 44);
cookiesStorageService.remove('cookieStorageVariable');
sharedStorageService.set('sharedStorageVariable', {a: 4});
sessionStorageService.set('twoDecorators', 44); // TODO make it working with change in sharedStorageService
sharedStorageService.set('twoDecorators', 44);
sessionStorageService.set('customKeyVariable', ['']);
cookiesStorageService.update('customObject', {anotherProperty: []});
sharedStorageService.set('arrayOfObjects', []);
Expand Down

0 comments on commit 4e5486b

Please sign in to comment.