Skip to content

Commit

Permalink
Remove quietly parameter from Concast#removeObserver method.
Browse files Browse the repository at this point in the history
I could swear I tried this before and it broke a bunch of tests, but
tests are passing without it.
  • Loading branch information
benjamn committed May 13, 2022
1 parent 2d3c1f3 commit 5446438
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
7 changes: 2 additions & 5 deletions src/core/ObservableQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -831,12 +831,9 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`);

if (!useDisposableConcast) {
// We use the {add,remove}Observer methods directly to avoid wrapping
// observer with an unnecessary SubscriptionObserver object, in part so
// that we can remove it here without triggering any unsubscriptions,
// because we just want to ignore the old observable, not prematurely shut
// it down, since other consumers may be awaiting this.concast.promise.
// observer with an unnecessary SubscriptionObserver object.
if (this.concast && this.observer) {
this.concast.removeObserver(this.observer, true);
this.concast.removeObserver(this.observer);
}

this.concast = concast;
Expand Down
2 changes: 1 addition & 1 deletion src/react/hoc/__tests__/queries/skip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ describe('[queries] skip', () => {
break;
case 4:
expect(this.props.skip).toBe(false);
expect(this.props.data!.loading).toBe(false);
expect(this.props.data!.loading).toBe(true);
expect(this.props.data.allPeople).toEqual(data.allPeople);
expect(ranQuery).toBe(2);
break;
Expand Down
19 changes: 6 additions & 13 deletions src/utilities/observables/Concast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,16 @@ export class Concast<T> extends Observable<T> {
}
}

public removeObserver(
observer: Observer<T>,
quietly?: boolean,
) {
public removeObserver(observer: Observer<T>) {
if (
this.observers.delete(observer) &&
this.observers.size < 1
) {
if (quietly) {
// In case there are still any listeners in this.nextResultListeners,
// and no error or completion has been broadcast yet, make sure those
// observers have a chance to run and then remove themselves from
// this.observers.
this.notify("complete");
} else {
this.handlers.complete();
}
// In case there are still any listeners in this.nextResultListeners, and
// no error or completion has been broadcast yet, make sure those
// observers have a chance to run and then remove themselves from
// this.observers.
this.handlers.complete();
}
}

Expand Down

0 comments on commit 5446438

Please sign in to comment.