-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Experimental support for AsyncSequence on Firestore snapshot listeners #11508
Draft
peterfriese
wants to merge
178
commits into
auth-swift
Choose a base branch
from
peterfriese/asyncsequence
base: auth-swift
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 6 commits
Commits
Show all changes
178 commits
Select commit
Hold shift + click to select a range
ec94f57
🧪 Experimental support for AsyncSequences on Firestore snapshot liste…
peterfriese e731d4b
🎨 Formatting
peterfriese 5286ea7
🔥 Remove superfluous method
peterfriese 50f5629
📝 Fix copyright
peterfriese 1e13834
✨ Add AsyncSequence support to DocumentReference
peterfriese 5a68fdf
🚚 Rename addSnapshotListener -> snapshotSequence
peterfriese 19b19f5
🐛 Use includeMetadataChanges parameter
peterfriese 9100d3a
✨ Show how to use AsyncSequence in a view model
peterfriese f19be90
💄 Style
peterfriese c6f5f9c
🧵 Make sure to not update from the background thread
peterfriese f25fbfe
[App Check] Fix JSON key ordering in `HeartbeatsPayload` (#11482)
andrewheard 027c2c0
Remove isFetchInProgress check for real-time initiated Fetches (#11465)
qdpham13 9aa5eaf
Firebase Auth TOTP support (#11261)
Xiaoshouzi-gh 5cc66dd
[Auth] Fix Firebase Auth build on visionOS (#11488)
andrewheard 59354df
[Messaging] Fix build issues on visionOS (#11483)
andrewheard 45e9dac
Analytics 10.12.0 (#11487)
htcgh 86bc06d
[Release] Update CHANGELOGs for 10.12.0 release (#11493)
ncooke3 59132d0
[Release] Minor changelog nits (#11495)
ncooke3 9303f32
[Release] Chandelog note about keychain access (#11496)
ncooke3 b80bf92
[visionOS] Provide support for building Firestore on visionOS (#11492)
ncooke3 acf2eb7
Add FID into real-time RC requests (#11485)
qdpham13 012d90c
[Firestore] Make Swift code compatible with Xcode 13.3.1 (#11497)
ncooke3 5bb6444
[Auth] Forward declare type in header (#11501)
ncooke3 cd2df6e
Add changelog entry for Remote Config (#11500)
qdpham13 5eaea70
[Release] Update Package.swift for 10.12.0 release (#11499)
ncooke3 93212e4
[Infra] Run 'zip / quickstart_framework_firestore' on Xcode 14 (#11503)
ncooke3 f99d40a
[Docs] Add a release note w.r.t. Xcode 15 Beta 1 support (#11510)
ncooke3 213e130
[Docs] s/workaround/work around/ in 10.12.0 release note (#11511)
ncooke3 97e7b25
[Crashlytics] update deprecated kernel api for visionPro (#11515)
themiswang 2683eeb
[Release] Update Carthage artifacts for Firebase 10.12.0 (#11528)
ncooke3 4aaafd2
Update to swiftformat 0.51.12 (#11531)
paulb777 30c03a6
checkpoint
paulb777 7537c01
Checkpoint - Subclassing fails at runtime in tests
paulb777 be5bc7a
Fails to find function
paulb777 e2c0a4c
Revert "Fails to find function"
paulb777 f31d377
Subclass override build failure
paulb777 b59dbe4
Revert "Subclass override build failure"
paulb777 190e42f
checkpoint
paulb777 b23e9ac
Clean unit tests, stub OauthProvider implementation
paulb777 71f8fd2
GameCenter Provider minus some error codes
paulb777 51a2fcd
port credential
paulb777 7e200eb
Port FIRAuthProvider strings to class property
paulb777 98e473a
Add Swift API tests to SPM build, port FederatedAuthProvider, and style
paulb777 687854a
AuthProviderStrings enum FR#9236 and tests
paulb777 cc52f2e
Checkpoint - partway through PhoneAuth implplementations
paulb777 7e6eae7
Some cleanup
paulb777 3946e90
checkpoint
paulb777 577d4f9
[WIP] Attempt at merging own ported swift code to official repo (#10696)
mortenbekditlevsen ccc6125
Changes to build with pod gen on mac (#10721)
paulb777 6150b76
Checkpoint PhoneProvider progress (#10722)
paulb777 43e212e
Style auth-swift (#10723)
paulb777 69f42ca
Converted FIRAuthUserDefaults and FIRAuthKeychainServices (#10731)
mortenbekditlevsen 304a7ea
Fix build warnings and style (#10735)
paulb777 cdc7648
[FirebaseAuth] Expose non-public headers to Swift and build on iOS (#…
ncooke3 1c1bab2
[auth-swift] Remove commented-out imports (#10776)
ncooke3 f9241bf
[auth-swift] Remove module.modulemap as it is unneeded (#10778)
ncooke3 1e9a2f7
Fix unit test failure (#10781)
paulb777 88af2dc
Migrate Auth RPC calls to Swift (#10806)
paulb777 dd167c5
Post rebase updates for #10805 and #10441
paulb777 fadbedd
[auth-swift] Re-enable logging code (pt. 1) (#10817)
ncooke3 935c397
Three more RPCs to Swift (#10816)
paulb777 c68be9c
[auth-swift] First mock replacements (#10820)
paulb777 27a301e
Converted a few more files
mortenbekditlevsen 73df2f1
[auth-swift] Styling #10819
paulb777 63d8484
[auth-swift] Depend on FirebaseCoreExtension rather than making it a …
ncooke3 5c8f089
[auth-swift] Re-enable logging code (pt. 2) (#10825)
ncooke3 76eb3a3
[auth-swift] Get 'FIRAuthKeychainServicesTests.m' tests passing (#10826)
ncooke3 cf4fad6
[auth-swift] Update AuthKeychainServices following #10759 (#10827)
ncooke3 0fa3828
[auth-swift] Resolve TODO by with 'FirebaseLogger' usage (#10828)
ncooke3 e7983a5
[auth-swift] Test improvements (#10829)
paulb777 605af7f
[auth-swift] Resolve missing implementation warning (#10830)
ncooke3 55cb94f
[auth-swift] Port 'FIRAuthKeychainServicesTests.m' -> 'AuthKeychainSe…
ncooke3 459274c
[auth-swift] Document flow in mock replacement test using fake (#10835)
paulb777 28ceaa1
[auth-swift] GetOOBConfirmationCode to Swift (#10837)
paulb777 97c09c7
[auth-swift] Fix test name (#10840)
ncooke3 197d600
[auth-swift] OAuthProvider and OAuthCredential (#10861)
paulb777 7362df7
[auth-swift] Initial Green CI (#10864)
paulb777 b3656f6
Two Password RPCs to Swift (#10866)
paulb777 1c902e5
[auth-swift] VerifyAssertion and SecureToken RPCs to Swift (#10888)
paulb777 3503d30
[auth-swift] CustomToken RPC to Swift (#10890)
paulb777 7af7693
[auth-swift] SignUpNewUser and SignInWithGameCenter RPC calls and uni…
paulb777 632a4c7
[auth-swift] MultiFactor and SendVerification RPC calls and unit test…
paulb777 161a02f
[auth-swift] VerifyClient RPC calls and unit tests (#10895)
paulb777 0c95953
[auth-swift] VerifyPhoneNumber RPC (#10897)
paulb777 6c01905
[auth-swift] Backend now completely in Swift (#10899)
paulb777 694db85
[auth-swift] Swift AuthDispatcher, two fakes, one test (#10903)
paulb777 a6086c6
[auth-swift] More AuthTests.swift (#10907)
paulb777 688d7dd
[auth-swift] More AuthTests.swift (#10909)
paulb777 f390411
RPCIssuer -> rpcIssuer (#10910)
paulb777 95255ce
[auth-swift] APNSToken.swift (#10918)
paulb777 a530172
[auth-swift] AuthAppCredentialManager.swift (#10927)
paulb777 3bb155a
[auth-swift] AuthDataResult.swift (#10928)
paulb777 2f91ec6
SecureTokenService.swift (#10938)
paulb777 ac422e2
[auth-swift] Restore integration tests (#10941)
paulb777 bd72660
[auth-swift] UserInfoImpl.swift and UserMetadata.swift (#10952)
paulb777 a02dacf
[auth-swift] Prep for keychain dependency injection (pt. 1) (#10976)
ncooke3 b6e8199
[auth-swift] Prep for keychain dependency injection (pt. 2) (#10990)
ncooke3 872e8dc
[auth-swift] Move AuthStorage protocol to own file; split up AuthKeyc…
ncooke3 57b0bac
[auth-swift] Migrate usage of FIRAuthKeychainServices to id<FIRAuthSt…
ncooke3 ba7bc9b
[auth-swift] Move keychain intitialization code into intializer (#10998)
ncooke3 3b5cd96
[auth-swift] Update initializer to accept keychain storage types (#11…
ncooke3 c42861a
AuthUser -> Swift (#10993)
paulb777 80ceca9
Reimplement #10068 in auth-swift after rebase (#11005)
paulb777 86333a2
Objective C property functions should be Swift computed properties (#…
paulb777 261574c
[auth-swift] User decoding and api cleanup (#11008)
paulb777 8f3f637
[auth-swift] Use stored keychain service at app cleanup (#11009)
ncooke3 a3a2b0a
[auth-swift] UserTests.swift Part 1 (#11013)
paulb777 e2011d9
AuthWebView and AuthWebViewController
mortenbekditlevsen 0a2d0b7
build and test
paulb777 dde9054
style
paulb777 8be8a12
Catalyst test fix and comments
paulb777 49b755e
[auth-swift] UserProfileChangeRequest.swift (#11015)
paulb777 5e6c4f8
[auth-swift] GetIDTokenResult unit tests (#11019)
paulb777 0726c0d
[auth-swift] User reload() unit tests and fix (#11023)
paulb777 81f77ec
[auth-swift] Make request components for deterministic to avoid test …
ncooke3 a0dddc7
[auth-swift] User reauthenticate unit tests (#11026)
paulb777 7a1f9b1
[auth-swift] Finish Auth refactoring to allow for injecting fake keyc…
ncooke3 e7984b0
[auth-swift] First user link swift unit test and a fix (#11042)
paulb777 193e047
[auth-swift] More User link unit tests (#11043)
paulb777 5daa1c3
[auth-swift] Two more User unit tests (#11048)
paulb777 fc4aa2b
[auth-swift] Progress on PhoneAuthProvider.swift (#11055)
paulb777 2669fbb
[auth-swift] Merge AppCheck integration (#11061)
paulb777 42cfdb7
[auth-swift] Two cleanups (#11062)
paulb777 105dae4
[auth-swift] AuthAppCredentialManager.swift (#11069)
paulb777 9e2629f
[auth-swift] AuthAppCredentialManagerTests.swift (#11076)
paulb777 912fa56
[auth-swift] RevokeToken.swift (#11083)
paulb777 cd01b8d
[auth-swift] AuthNotificationManager (#11088)
paulb777 da7eddf
[auth-swift] Phone Auth progress (#11089)
paulb777 89bbe74
[auth-swift] AuthURLPresenter implementation and PhoneAuth request (#…
paulb777 1dc9a62
[auth-swift] AuthDefaultUIDelegate.swift and AuthURLPresenterTests.sw…
paulb777 6015dde
[auth-swift] Fix test by using DataWrapper API (#11099)
ncooke3 aa8924e
Checkpoint after first Phone Auth Rechaptcha unit test (#11106)
paulb777 a9f09dc
[auth-swift] Port 'FIRAuthStoredUserManager' (#11109)
ncooke3 244eae2
[auth-swift] More PhoneAuth Recaptcha tests (#11110)
paulb777 b30dc34
[auth-swift] More PhoneAuth unit tests (#11115)
paulb777 885602f
Pb more phone auth unit (#11126)
paulb777 3b33c75
[auth-swift] Finish PhoneAuthProviderTests.swift (#11130)
paulb777 72ca940
[auth-swift] Some unit test cleanup (#11133)
paulb777 caa7c3b
[auth-swift] Seven PhoneAuth related tests in UserTests.swift (#11172)
paulb777 8901863
[auth-swift] ActionCode classes to Swift (#11181)
paulb777 a4fa5ab
[auth-swift] Auth.swift (#11237)
paulb777 06446be
[auth-swift] Queue implementations and tests to Swift-only (#11249)
paulb777 4755623
[auth-swift] Eliminate FIRAuthExceptionUtils.m (#11251)
paulb777 2d86bf8
[auth-swift] AuthAPNSTokenType.swift (#11252)
paulb777 9d65c37
[auth-swift] PhoneMultiFactorGenerator.swift and more cleanup (#11258)
paulb777 ee94bd6
[auth-swift] unowned instead of weak for holding app in the component…
paulb777 bab85e9
[auth-swift] MultiFactorResolver.swift and MultiFactor.swift (#11262)
paulb777 9d24ecc
[auth-swift] AuthUIDelegate.swift (#11274)
paulb777 05eab69
[auth-swift] AuthSettings.swift (#11278)
paulb777 2514785
[auth-swift] CocoaPods Swift-only sources (#11279)
paulb777 85786e6
[auth-swift] Restore SPM (#11280)
paulb777 9350bbb
[auth-swift] AdditionalUserInfoTests.swift (#11283)
paulb777 be1dbb1
[auth-swift] AuthAPNSTokenManagerTests.swift (#11331)
paulb777 a8b3313
[auth-swift] AuthAPNSTokenTests.swift (#11335)
paulb777 f867cdc
[auth-swift] AuthAppCredentialTests.swift (#11336)
paulb777 73f4192
[auth-swift] AuthDispatcherTests.swift (#11339)
paulb777 322a305
[auth-swift] AuthLifecycleTests.swift (#11341)
paulb777 ace7dc4
[auth-swift] AuthUserDefaultsTests.swift (#11343)
paulb777 bf62ad8
[auth-swift] GitHubAuthProviderTests.swift and TwitterAuthProviderTes…
paulb777 6c6c034
[auth-swift] IdentityToolkitRequestTests.swift (#11346)
paulb777 7e6eb41
[auth-swift] Finish unit test Swiftification (#11348)
paulb777 cf6a8a2
[auth-swift] AuthTests.swift - 15 more unit tests (#11357)
paulb777 9f73315
More AuthTests.swift implementation (#11360)
paulb777 cecee45
[auth-swift] Refresh Tokens implementation and first test (#11373)
paulb777 447b15c
[auth-swift] Rest of token refresh unit tests (#11382)
paulb777 2e33715
[auth-swift] Rest of token refresh unit tests (#11387)
paulb777 78f3a2f
[auth-swift] Revoke Token unit tests (#11391)
paulb777 94bab05
[auth-swift] UserTests.swift progress (#11420)
paulb777 acbee63
[auth-swift] Bump to iOS 13, etc. (#11429)
paulb777 dc380a7
[auth-swift] associated type enum for PhoneAuthCredential (#11443)
paulb777 b0fd40e
[auth-swift] Finish coding coverage and fixes (#11445)
paulb777 c39dca7
[auth-swift] Refactor keychain implementation and tests (#11453)
paulb777 330ee81
Fix runtime warnings detected by Xcode 15 b3 (#11518)
paulb777 a2087fd
[auth-swift] Address a few todos (#11525)
paulb777 caea41a
[auth-swift] Rewrite Auth RPC types using Swift types (#11529)
paulb777 00bcca2
Post rebase style and other fixes
paulb777 d33ce7c
🚧 Add AsyncSequence for Auth
peterfriese 6e00b72
🚧 AsyncSequences WIP
peterfriese File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
Example/FirestoreSample/FirestoreSample/Views/FavouriteFruitView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import SwiftUI | ||
import FirebaseFirestore | ||
import FirebaseFirestoreSwift | ||
|
||
private struct Fruit: Codable, Identifiable, Equatable { | ||
@DocumentID var id: String? | ||
var name: String | ||
var isFavourite: Bool | ||
} | ||
|
||
extension Fruit { | ||
static let empty = Fruit(name: "", isFavourite: false) | ||
} | ||
|
||
struct FavouriteFruitView: View { | ||
@State fileprivate var fruit: Fruit = .empty | ||
|
||
var body: some View { | ||
VStack { | ||
Text(fruit.name) | ||
Toggle(isOn: $fruit.isFavourite, label: { | ||
Text("Is favourite") | ||
}) | ||
} | ||
.task { | ||
do { | ||
let doc = Firestore.firestore().collection("fruits").document("1uxSAlCvYWmfrXN7rn2s") | ||
for try await fruit in doc.snapshotSequence(Fruit.self) { | ||
self.fruit = fruit | ||
} | ||
} catch { | ||
print(error) | ||
} | ||
} | ||
.navigationTitle("Fruit") | ||
} | ||
} | ||
|
||
struct FavouriteFruitView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
FavouriteFruitView() | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
Example/FirestoreSample/FirestoreSample/Views/FavouriteFruitsAsyncSequenceView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import SwiftUI | ||
import FirebaseFirestore | ||
import FirebaseFirestoreSwift | ||
|
||
private struct Fruit: Codable, Identifiable, Equatable { | ||
@DocumentID var id: String? | ||
var name: String | ||
var isFavourite: Bool | ||
} | ||
|
||
struct FavouriteFruitsAsyncSequenceView: View { | ||
@State fileprivate var fruits: [Fruit] = [] | ||
|
||
@State var showOnlyFavourites = true | ||
|
||
var body: some View { | ||
List(fruits) { fruit in | ||
Text(fruit.name) | ||
} | ||
.task { | ||
do { | ||
let collection = Firestore.firestore().collection("fruits") | ||
for try await fruits in collection.snapshotSequence(Fruit.self) { | ||
self.fruits = fruits | ||
} | ||
} catch { | ||
print(error) | ||
} | ||
} | ||
.animation(.default, value: fruits) | ||
.navigationTitle("Fruits") | ||
.toolbar { | ||
ToolbarItem(placement: .navigationBarTrailing) { | ||
Button(action: toggleFilter) { | ||
Image(systemName: showOnlyFavourites | ||
? "line.3.horizontal.decrease.circle.fill" | ||
: "line.3.horizontal.decrease.circle") | ||
} | ||
} | ||
} | ||
} | ||
|
||
func toggleFilter() { | ||
showOnlyFavourites.toggle() | ||
} | ||
} | ||
|
||
struct FavouriteFruitsAsyncSequenceView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
FavouriteFruitsAsyncSequenceView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
Firestore/Swift/Source/AsyncAwait/DocumentReference+AsyncStream.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import FirebaseFirestore | ||
import Foundation | ||
|
||
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *) | ||
public extension DocumentReference { | ||
func snapshotSequence<T>(_ type: T.Type, | ||
includeMetadataChanges: Bool = false) | ||
-> AsyncThrowingStream<T, Error> where T: Decodable { | ||
.init { continuation in | ||
let listener = addSnapshotListener(includeMetadataChanges: false) { documentSnapshot, error in | ||
do { | ||
if let result = try documentSnapshot?.data(as: T.self) { | ||
continuation.yield(result) | ||
} | ||
} catch { | ||
continuation.finish(throwing: error) | ||
} | ||
} | ||
|
||
continuation.onTermination = { @Sendable _ in | ||
listener.remove() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import FirebaseFirestore | ||
import Foundation | ||
|
||
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *) | ||
public extension Query { | ||
func snapshotSequence<T>(_ type: T.Type, | ||
includeMetadataChanges: Bool = false) -> AsyncThrowingStream< | ||
[T], | ||
Error | ||
> where T: Decodable { | ||
.init { continuation in | ||
let listener = | ||
addSnapshotListener(includeMetadataChanges: includeMetadataChanges) { querySnapshot, error in | ||
do { | ||
guard let documents = querySnapshot?.documents else { | ||
continuation.yield([]) | ||
return | ||
} | ||
let results = try documents.map { try $0.data(as: T.self) } | ||
continuation.yield(results) | ||
} catch { | ||
continuation.finish(throwing: error) | ||
} | ||
} | ||
|
||
continuation.onTermination = { @Sendable _ in | ||
listener.remove() | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.