Skip to content

Commit

Permalink
Check structural equality in QueryInfo#setDiff, again.
Browse files Browse the repository at this point in the history
Revisiting PR #6891, which was reverted by commit c2ef68f.

With the introduction of canonical cache results (#7439), the strict
equality check in setDiff is about to become mostly synonymous with deep
equality checking (but much faster to check), so we need to deal with the
consequences of #6891 one way or another.

As evidence that this change now (after #7439) has no observable impact,
notice that we were able to switch back to using !equal(a, b) without
needing to fix/update any failing tests, compared to the few tests that
needed updating in #6891.

However, by switching to deep equality checking, we allow ourselves the
option to experiment with disabling (or periodically clearing) the
ObjectCanon, which would presumably lead to broadcasting more !== but
deeply equal results to cache.watch watchers.

With deep equality checking in setDiff, those !== results will get past
the filter in the same cases canonical objects would, so there's less of a
discrepancy in client behavior with/without canonization enabled.
  • Loading branch information
benjamn committed Apr 16, 2021
1 parent 337e2f9 commit 4f1babc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/QueryInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ export class QueryInfo {
const oldDiff = this.diff;
this.diff = diff;
if (!this.dirty &&
(diff && diff.result) !== (oldDiff && oldDiff.result)) {
!equal(oldDiff && oldDiff.result,
diff && diff.result)) {
this.dirty = true;
if (!this.notifyTimeout) {
this.notifyTimeout = setTimeout(() => this.notify(), 0);
Expand Down

0 comments on commit 4f1babc

Please sign in to comment.