Skip to content

Commit

Permalink
Update Cache.js
Browse files Browse the repository at this point in the history
bug fix: when adding/putting data, if the target store returns a non-null result object, use it to update caching store, otherwise use the original data object.
wrong expr: "object && typeof result === 'object' ? result : object"
right expr: "result && typeof result === 'object' ? result : object"
  • Loading branch information
rainmanhhh authored and msssk committed Jan 7, 2020
1 parent c69b07c commit e9d88db
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ define([
// now put result in cache (note we don't do add, because add may have
// called put() and already added it)
var cachedPutResult =
cachingStore.put(object && typeof result === 'object' ? result : object, directives);
cachingStore.put(result && typeof result === 'object' ? result : object, directives);
// the result from the add should be dictated by the master store and be unaffected by the cachingStore,
// unless the master store doesn't implement add
return result || cachedPutResult;
Expand All @@ -154,7 +154,7 @@ define([
return when(this.inherited(arguments)).then(function (result) {
// now put result in cache
var cachedPutResult =
cachingStore.put(object && typeof result === 'object' ? result : object, directives);
cachingStore.put(result && typeof result === 'object' ? result : object, directives);
// the result from the put should be dictated by the master store and be unaffected by the cachingStore,
// unless the master store doesn't implement put
return result || cachedPutResult;
Expand Down

0 comments on commit e9d88db

Please sign in to comment.