-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Experimental support for AsyncSequence on Firestore snapshot listeners #11508
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
base: auth-swift
Are you sure you want to change the base?
Conversation
…ners Signed-off-by: Peter Friese <peter@peterfriese.de>
Generated by 🚫 Danger |
Apple API Diff ReportCommit: f9781a0 FirebaseFirestoreSwiftExtensions[ADDED] Query[ADDED] QuerySwift:
+ public extension Query
+ func snapshotSequence < T > ( _ type : T . Type , includeMetadataChanges : Bool = false ) -> AsyncThrowingStream < [ T ], Error > where T : Decodable [MODIFIED] DocumentReference[MODIFIED] DocumentReferenceSwift:
+ public extension DocumentReference extension DocumentReference : DocumentIDWrappable
- extension DocumentReference : DocumentIDWrappable
+ func snapshotSequence < T > ( _ type : T . Type , includeMetadataChanges : Bool = false ) -> AsyncThrowingStream < T , Error > where T : Decodable |
Signed-off-by: Peter Friese <peter@peterfriese.de>
Signed-off-by: Peter Friese <peter@peterfriese.de>
Signed-off-by: Peter Friese <peter@peterfriese.de>
Coverage Report 1Affected Products
Test Logs |
import FirebaseFirestore | ||
import Foundation | ||
|
||
#if compiler(>=5.5.2) && canImport(_Concurrency) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this check anymore with our current Xcode supported versions
Example/FirestoreSample/FirestoreSample/Views/FavouriteFruitsAsyncSequenceView.swift
Outdated
Show resolved
Hide resolved
It could also make sense to have a similar abstraction for a document rather than a query. |
Signed-off-by: Peter Friese <peter@peterfriese.de>
Good point. Added! |
Signed-off-by: Peter Friese <peter@peterfriese.de>
includeMetadataChanges: Bool = false) | ||
-> AsyncThrowingStream<T, Error> where T: Decodable { | ||
.init { continuation in | ||
let listener = addSnapshotListener(includeMetadataChanges: false) { documentSnapshot, error in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably use the argument passed to the method.
Signed-off-by: Peter Friese <peter@peterfriese.de>
Signed-off-by: Peter Friese <peter@peterfriese.de>
* Rewrite Auth RPC types using Swift types. This largely stems from the unsafe casting that occurs. Current state: all types have been converted, almost no calls using those types have been converted, ran into an issue with TwitterAuthCredential where it takes a parameter that's an RPC type, but can't be visible in ObjC. This may result in an API change unfortunately, or a rethinking of how the AuthCredential and Providers work. --------- Co-authored-by: Ryan Wilson <wilsonryan@google.com>
Signed-off-by: Peter Friese <peter@peterfriese.de>
Signed-off-by: Peter Friese <peter@peterfriese.de>
Looks likes you might have had an out of date |
Please close, merge, or comment. We plan to close stale PRs on November 28, 2023. |
I'd like to land this in Q4. Will rebase on the latest |
This PR adds support for using Swift's
AsyncSequence
to listen to changes on Firestore collections and documents.Here is how to use it:
Listening to updates on a single document
Listening to updates on a collection
See
Example/FirestoreSample/FirestoreSample/Views/FavouriteFruitsAsyncSequenceView.swift
andExample/FirestoreSample/FirestoreSample/Views/FavouriteFruitView.swift
for more complete examples how to use this.