Skip to content

Commit

Permalink
fix(CacheItem): avoid propagating change if value hasn't changed
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielKucal committed Feb 17, 2018
1 parent bcb2229 commit fdf3fb0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/decorator/cache-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Config, debug } from '../config/index';
import { DecoratorConfig } from './webstorage';
import { Cache } from './cache';

const isEqual = require('lodash.isequal');

export interface CacheItemInterface {
key: string;
name: string;
Expand Down Expand Up @@ -159,9 +161,11 @@ export class CacheItem implements CacheItemInterface {
}

protected propagateChange(value: any, config: DecoratorConfig, source) {
if (isEqual(value, this.readValue(config))) return;
this.utilities.forEach(utility => {
// updating service which the change came from would affect in a cycle
if (utility === source) return;
debug.log(`propagating change on ${this.key} to:`, utility);
utility.set(this._key, value, config);
});
}
Expand Down

0 comments on commit fdf3fb0

Please sign in to comment.