Skip to content

Make onSnapshot work with rxjs observers #3318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/thin-ligers-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@firebase/firestore": patch
"firebase": patch
---

Fixed an issue where `onSnapshot` doesn't work with rxjs [Observer](https://rxjs-dev.firebaseapp.com/guide/observer).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, the change that broke this was merged on Friday and never released.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which one is it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Changed to an empty changeset.

12 changes: 6 additions & 6 deletions packages/firestore/src/api/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1169,9 +1169,9 @@ export class DocumentReference<T = firestore.DocumentData>
const userObserver = args[currArg] as PartialObserver<
firestore.DocumentSnapshot<T>
>;
args[currArg] = userObserver.next;
args[currArg + 1] = userObserver.error;
args[currArg + 2] = userObserver.complete;
args[currArg] = userObserver.next?.bind(userObserver);
args[currArg + 1] = userObserver.error?.bind(userObserver);
args[currArg + 2] = userObserver.complete?.bind(userObserver);
} else {
validateArgType(
'DocumentReference.onSnapshot',
Expand Down Expand Up @@ -2122,9 +2122,9 @@ export class Query<T = firestore.DocumentData> extends BaseQuery
const userObserver = args[currArg] as PartialObserver<
firestore.QuerySnapshot<T>
>;
args[currArg] = userObserver.next;
args[currArg + 1] = userObserver.error;
args[currArg + 2] = userObserver.complete;
args[currArg] = userObserver.next?.bind(userObserver);
args[currArg + 1] = userObserver.error?.bind(userObserver);
args[currArg + 2] = userObserver.complete?.bind(userObserver);
} else {
validateArgType('Query.onSnapshot', 'function', currArg, args[currArg]);
validateOptionalArgType(
Expand Down