Skip to content
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
wants to merge 178 commits into
base: auth-swift
Choose a base branch
from
Draft
Show file tree
Hide file tree
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 Jul 5, 2023
e731d4b
🎨 Formatting
peterfriese Jul 5, 2023
5286ea7
🔥 Remove superfluous method
peterfriese Jul 5, 2023
50f5629
📝 Fix copyright
peterfriese Jul 5, 2023
1e13834
✨ Add AsyncSequence support to DocumentReference
peterfriese Jul 7, 2023
5a68fdf
🚚 Rename addSnapshotListener -> snapshotSequence
peterfriese Jul 7, 2023
19b19f5
🐛 Use includeMetadataChanges parameter
peterfriese Jul 7, 2023
9100d3a
✨ Show how to use AsyncSequence in a view model
peterfriese Jul 7, 2023
f19be90
💄 Style
peterfriese Jul 7, 2023
c6f5f9c
🧵 Make sure to not update from the background thread
peterfriese Jul 7, 2023
f25fbfe
[App Check] Fix JSON key ordering in `HeartbeatsPayload` (#11482)
andrewheard Jun 27, 2023
027c2c0
Remove isFetchInProgress check for real-time initiated Fetches (#11465)
qdpham13 Jun 28, 2023
9aa5eaf
Firebase Auth TOTP support (#11261)
Xiaoshouzi-gh Jun 29, 2023
5cc66dd
[Auth] Fix Firebase Auth build on visionOS (#11488)
andrewheard Jun 29, 2023
59354df
[Messaging] Fix build issues on visionOS (#11483)
andrewheard Jun 29, 2023
45e9dac
Analytics 10.12.0 (#11487)
htcgh Jun 29, 2023
86bc06d
[Release] Update CHANGELOGs for 10.12.0 release (#11493)
ncooke3 Jun 29, 2023
59132d0
[Release] Minor changelog nits (#11495)
ncooke3 Jun 29, 2023
9303f32
[Release] Chandelog note about keychain access (#11496)
ncooke3 Jun 29, 2023
b80bf92
[visionOS] Provide support for building Firestore on visionOS (#11492)
ncooke3 Jun 29, 2023
acf2eb7
Add FID into real-time RC requests (#11485)
qdpham13 Jun 29, 2023
012d90c
[Firestore] Make Swift code compatible with Xcode 13.3.1 (#11497)
ncooke3 Jun 30, 2023
5bb6444
[Auth] Forward declare type in header (#11501)
ncooke3 Jun 30, 2023
cd2df6e
Add changelog entry for Remote Config (#11500)
qdpham13 Jun 30, 2023
5eaea70
[Release] Update Package.swift for 10.12.0 release (#11499)
ncooke3 Jul 1, 2023
93212e4
[Infra] Run 'zip / quickstart_framework_firestore' on Xcode 14 (#11503)
ncooke3 Jul 4, 2023
f99d40a
[Docs] Add a release note w.r.t. Xcode 15 Beta 1 support (#11510)
ncooke3 Jul 6, 2023
213e130
[Docs] s/workaround/work around/ in 10.12.0 release note (#11511)
ncooke3 Jul 6, 2023
97e7b25
[Crashlytics] update deprecated kernel api for visionPro (#11515)
themiswang Jul 10, 2023
2683eeb
[Release] Update Carthage artifacts for Firebase 10.12.0 (#11528)
ncooke3 Jul 11, 2023
4aaafd2
Update to swiftformat 0.51.12 (#11531)
paulb777 Jul 11, 2023
30c03a6
checkpoint
paulb777 Dec 30, 2022
7537c01
Checkpoint - Subclassing fails at runtime in tests
paulb777 Jan 4, 2023
be5bc7a
Fails to find function
paulb777 Jan 4, 2023
e2c0a4c
Revert "Fails to find function"
paulb777 Jan 4, 2023
f31d377
Subclass override build failure
paulb777 Jan 4, 2023
b59dbe4
Revert "Subclass override build failure"
paulb777 Jan 4, 2023
190e42f
checkpoint
paulb777 Jan 5, 2023
b23e9ac
Clean unit tests, stub OauthProvider implementation
paulb777 Jan 6, 2023
71f8fd2
GameCenter Provider minus some error codes
paulb777 Jan 6, 2023
51a2fcd
port credential
paulb777 Jan 6, 2023
7e200eb
Port FIRAuthProvider strings to class property
paulb777 Jan 6, 2023
98e473a
Add Swift API tests to SPM build, port FederatedAuthProvider, and style
paulb777 Jan 6, 2023
687854a
AuthProviderStrings enum FR#9236 and tests
paulb777 Jan 6, 2023
cc52f2e
Checkpoint - partway through PhoneAuth implplementations
paulb777 Jan 11, 2023
7e6eae7
Some cleanup
paulb777 Jan 11, 2023
3946e90
checkpoint
paulb777 Jan 13, 2023
577d4f9
[WIP] Attempt at merging own ported swift code to official repo (#10696)
mortenbekditlevsen Jan 20, 2023
ccc6125
Changes to build with pod gen on mac (#10721)
paulb777 Jan 20, 2023
6150b76
Checkpoint PhoneProvider progress (#10722)
paulb777 Jan 20, 2023
43e212e
Style auth-swift (#10723)
paulb777 Jan 20, 2023
69f42ca
Converted FIRAuthUserDefaults and FIRAuthKeychainServices (#10731)
mortenbekditlevsen Jan 24, 2023
304a7ea
Fix build warnings and style (#10735)
paulb777 Jan 24, 2023
cdc7648
[FirebaseAuth] Expose non-public headers to Swift and build on iOS (#…
ncooke3 Feb 3, 2023
1c1bab2
[auth-swift] Remove commented-out imports (#10776)
ncooke3 Feb 3, 2023
f9241bf
[auth-swift] Remove module.modulemap as it is unneeded (#10778)
ncooke3 Feb 4, 2023
1e9a2f7
Fix unit test failure (#10781)
paulb777 Feb 6, 2023
88af2dc
Migrate Auth RPC calls to Swift (#10806)
paulb777 Feb 11, 2023
dd167c5
Post rebase updates for #10805 and #10441
paulb777 Feb 11, 2023
fadbedd
[auth-swift] Re-enable logging code (pt. 1) (#10817)
ncooke3 Feb 14, 2023
935c397
Three more RPCs to Swift (#10816)
paulb777 Feb 14, 2023
c68be9c
[auth-swift] First mock replacements (#10820)
paulb777 Feb 15, 2023
27a301e
Converted a few more files
mortenbekditlevsen Feb 14, 2023
73df2f1
[auth-swift] Styling #10819
paulb777 Feb 15, 2023
63d8484
[auth-swift] Depend on FirebaseCoreExtension rather than making it a …
ncooke3 Feb 15, 2023
5c8f089
[auth-swift] Re-enable logging code (pt. 2) (#10825)
ncooke3 Feb 15, 2023
76eb3a3
[auth-swift] Get 'FIRAuthKeychainServicesTests.m' tests passing (#10826)
ncooke3 Feb 15, 2023
cf4fad6
[auth-swift] Update AuthKeychainServices following #10759 (#10827)
ncooke3 Feb 16, 2023
0fa3828
[auth-swift] Resolve TODO by with 'FirebaseLogger' usage (#10828)
ncooke3 Feb 16, 2023
e7983a5
[auth-swift] Test improvements (#10829)
paulb777 Feb 16, 2023
605af7f
[auth-swift] Resolve missing implementation warning (#10830)
ncooke3 Feb 16, 2023
55cb94f
[auth-swift] Port 'FIRAuthKeychainServicesTests.m' -> 'AuthKeychainSe…
ncooke3 Feb 16, 2023
459274c
[auth-swift] Document flow in mock replacement test using fake (#10835)
paulb777 Feb 16, 2023
28ceaa1
[auth-swift] GetOOBConfirmationCode to Swift (#10837)
paulb777 Feb 17, 2023
97c09c7
[auth-swift] Fix test name (#10840)
ncooke3 Feb 17, 2023
197d600
[auth-swift] OAuthProvider and OAuthCredential (#10861)
paulb777 Feb 24, 2023
7362df7
[auth-swift] Initial Green CI (#10864)
paulb777 Feb 24, 2023
b3656f6
Two Password RPCs to Swift (#10866)
paulb777 Feb 25, 2023
1c902e5
[auth-swift] VerifyAssertion and SecureToken RPCs to Swift (#10888)
paulb777 Mar 3, 2023
3503d30
[auth-swift] CustomToken RPC to Swift (#10890)
paulb777 Mar 3, 2023
7af7693
[auth-swift] SignUpNewUser and SignInWithGameCenter RPC calls and uni…
paulb777 Mar 3, 2023
632a4c7
[auth-swift] MultiFactor and SendVerification RPC calls and unit test…
paulb777 Mar 3, 2023
161a02f
[auth-swift] VerifyClient RPC calls and unit tests (#10895)
paulb777 Mar 4, 2023
0c95953
[auth-swift] VerifyPhoneNumber RPC (#10897)
paulb777 Mar 4, 2023
6c01905
[auth-swift] Backend now completely in Swift (#10899)
paulb777 Mar 7, 2023
694db85
[auth-swift] Swift AuthDispatcher, two fakes, one test (#10903)
paulb777 Mar 7, 2023
a6086c6
[auth-swift] More AuthTests.swift (#10907)
paulb777 Mar 8, 2023
688d7dd
[auth-swift] More AuthTests.swift (#10909)
paulb777 Mar 8, 2023
f390411
RPCIssuer -> rpcIssuer (#10910)
paulb777 Mar 8, 2023
95255ce
[auth-swift] APNSToken.swift (#10918)
paulb777 Mar 9, 2023
a530172
[auth-swift] AuthAppCredentialManager.swift (#10927)
paulb777 Mar 10, 2023
3bb155a
[auth-swift] AuthDataResult.swift (#10928)
paulb777 Mar 10, 2023
2f91ec6
SecureTokenService.swift (#10938)
paulb777 Mar 11, 2023
ac422e2
[auth-swift] Restore integration tests (#10941)
paulb777 Mar 13, 2023
bd72660
[auth-swift] UserInfoImpl.swift and UserMetadata.swift (#10952)
paulb777 Mar 13, 2023
a02dacf
[auth-swift] Prep for keychain dependency injection (pt. 1) (#10976)
ncooke3 Mar 22, 2023
b6e8199
[auth-swift] Prep for keychain dependency injection (pt. 2) (#10990)
ncooke3 Mar 22, 2023
872e8dc
[auth-swift] Move AuthStorage protocol to own file; split up AuthKeyc…
ncooke3 Mar 23, 2023
57b0bac
[auth-swift] Migrate usage of FIRAuthKeychainServices to id<FIRAuthSt…
ncooke3 Mar 23, 2023
ba7bc9b
[auth-swift] Move keychain intitialization code into intializer (#10998)
ncooke3 Mar 23, 2023
3b5cd96
[auth-swift] Update initializer to accept keychain storage types (#11…
ncooke3 Mar 23, 2023
c42861a
AuthUser -> Swift (#10993)
paulb777 Mar 24, 2023
80ceca9
Reimplement #10068 in auth-swift after rebase (#11005)
paulb777 Mar 24, 2023
86333a2
Objective C property functions should be Swift computed properties (#…
paulb777 Mar 24, 2023
261574c
[auth-swift] User decoding and api cleanup (#11008)
paulb777 Mar 24, 2023
8f3f637
[auth-swift] Use stored keychain service at app cleanup (#11009)
ncooke3 Mar 25, 2023
a3a2b0a
[auth-swift] UserTests.swift Part 1 (#11013)
paulb777 Mar 26, 2023
e2011d9
AuthWebView and AuthWebViewController
mortenbekditlevsen Mar 26, 2023
0a2d0b7
build and test
paulb777 Mar 26, 2023
dde9054
style
paulb777 Mar 26, 2023
8be8a12
Catalyst test fix and comments
paulb777 Mar 26, 2023
49b755e
[auth-swift] UserProfileChangeRequest.swift (#11015)
paulb777 Mar 26, 2023
5e6c4f8
[auth-swift] GetIDTokenResult unit tests (#11019)
paulb777 Mar 27, 2023
0726c0d
[auth-swift] User reload() unit tests and fix (#11023)
paulb777 Mar 27, 2023
81f77ec
[auth-swift] Make request components for deterministic to avoid test …
ncooke3 Mar 28, 2023
a0dddc7
[auth-swift] User reauthenticate unit tests (#11026)
paulb777 Mar 28, 2023
7a1f9b1
[auth-swift] Finish Auth refactoring to allow for injecting fake keyc…
ncooke3 Mar 29, 2023
e7984b0
[auth-swift] First user link swift unit test and a fix (#11042)
paulb777 Mar 30, 2023
193e047
[auth-swift] More User link unit tests (#11043)
paulb777 Mar 30, 2023
5daa1c3
[auth-swift] Two more User unit tests (#11048)
paulb777 Mar 31, 2023
fc4aa2b
[auth-swift] Progress on PhoneAuthProvider.swift (#11055)
paulb777 Mar 31, 2023
2669fbb
[auth-swift] Merge AppCheck integration (#11061)
paulb777 Apr 2, 2023
42cfdb7
[auth-swift] Two cleanups (#11062)
paulb777 Apr 3, 2023
105dae4
[auth-swift] AuthAppCredentialManager.swift (#11069)
paulb777 Apr 4, 2023
9e2629f
[auth-swift] AuthAppCredentialManagerTests.swift (#11076)
paulb777 Apr 5, 2023
912fa56
[auth-swift] RevokeToken.swift (#11083)
paulb777 Apr 5, 2023
cd01b8d
[auth-swift] AuthNotificationManager (#11088)
paulb777 Apr 7, 2023
da7eddf
[auth-swift] Phone Auth progress (#11089)
paulb777 Apr 7, 2023
89bbe74
[auth-swift] AuthURLPresenter implementation and PhoneAuth request (#…
paulb777 Apr 9, 2023
1dc9a62
[auth-swift] AuthDefaultUIDelegate.swift and AuthURLPresenterTests.sw…
paulb777 Apr 10, 2023
6015dde
[auth-swift] Fix test by using DataWrapper API (#11099)
ncooke3 Apr 11, 2023
aa8924e
Checkpoint after first Phone Auth Rechaptcha unit test (#11106)
paulb777 Apr 11, 2023
a9f09dc
[auth-swift] Port 'FIRAuthStoredUserManager' (#11109)
ncooke3 Apr 11, 2023
244eae2
[auth-swift] More PhoneAuth Recaptcha tests (#11110)
paulb777 Apr 12, 2023
b30dc34
[auth-swift] More PhoneAuth unit tests (#11115)
paulb777 Apr 13, 2023
885602f
Pb more phone auth unit (#11126)
paulb777 Apr 14, 2023
3b33c75
[auth-swift] Finish PhoneAuthProviderTests.swift (#11130)
paulb777 Apr 14, 2023
72ca940
[auth-swift] Some unit test cleanup (#11133)
paulb777 Apr 14, 2023
caa7c3b
[auth-swift] Seven PhoneAuth related tests in UserTests.swift (#11172)
paulb777 Apr 24, 2023
8901863
[auth-swift] ActionCode classes to Swift (#11181)
paulb777 Apr 25, 2023
a4fa5ab
[auth-swift] Auth.swift (#11237)
paulb777 May 8, 2023
06446be
[auth-swift] Queue implementations and tests to Swift-only (#11249)
paulb777 May 9, 2023
4755623
[auth-swift] Eliminate FIRAuthExceptionUtils.m (#11251)
paulb777 May 9, 2023
2d86bf8
[auth-swift] AuthAPNSTokenType.swift (#11252)
paulb777 May 9, 2023
9d65c37
[auth-swift] PhoneMultiFactorGenerator.swift and more cleanup (#11258)
paulb777 May 9, 2023
ee94bd6
[auth-swift] unowned instead of weak for holding app in the component…
paulb777 May 10, 2023
bab85e9
[auth-swift] MultiFactorResolver.swift and MultiFactor.swift (#11262)
paulb777 May 10, 2023
9d24ecc
[auth-swift] AuthUIDelegate.swift (#11274)
paulb777 May 11, 2023
05eab69
[auth-swift] AuthSettings.swift (#11278)
paulb777 May 11, 2023
2514785
[auth-swift] CocoaPods Swift-only sources (#11279)
paulb777 May 11, 2023
85786e6
[auth-swift] Restore SPM (#11280)
paulb777 May 12, 2023
9350bbb
[auth-swift] AdditionalUserInfoTests.swift (#11283)
paulb777 May 12, 2023
be1dbb1
[auth-swift] AuthAPNSTokenManagerTests.swift (#11331)
paulb777 May 26, 2023
a8b3313
[auth-swift] AuthAPNSTokenTests.swift (#11335)
paulb777 May 26, 2023
f867cdc
[auth-swift] AuthAppCredentialTests.swift (#11336)
paulb777 May 26, 2023
73f4192
[auth-swift] AuthDispatcherTests.swift (#11339)
paulb777 May 26, 2023
322a305
[auth-swift] AuthLifecycleTests.swift (#11341)
paulb777 May 26, 2023
ace7dc4
[auth-swift] AuthUserDefaultsTests.swift (#11343)
paulb777 May 27, 2023
bf62ad8
[auth-swift] GitHubAuthProviderTests.swift and TwitterAuthProviderTes…
paulb777 May 28, 2023
6c6c034
[auth-swift] IdentityToolkitRequestTests.swift (#11346)
paulb777 May 28, 2023
7e6eb41
[auth-swift] Finish unit test Swiftification (#11348)
paulb777 May 28, 2023
cf6a8a2
[auth-swift] AuthTests.swift - 15 more unit tests (#11357)
paulb777 May 30, 2023
9f73315
More AuthTests.swift implementation (#11360)
paulb777 May 31, 2023
cecee45
[auth-swift] Refresh Tokens implementation and first test (#11373)
paulb777 Jun 1, 2023
447b15c
[auth-swift] Rest of token refresh unit tests (#11382)
paulb777 Jun 2, 2023
2e33715
[auth-swift] Rest of token refresh unit tests (#11387)
paulb777 Jun 3, 2023
78f3a2f
[auth-swift] Revoke Token unit tests (#11391)
paulb777 Jun 9, 2023
94bab05
[auth-swift] UserTests.swift progress (#11420)
paulb777 Jun 10, 2023
acbee63
[auth-swift] Bump to iOS 13, etc. (#11429)
paulb777 Jun 13, 2023
dc380a7
[auth-swift] associated type enum for PhoneAuthCredential (#11443)
paulb777 Jun 15, 2023
b0fd40e
[auth-swift] Finish coding coverage and fixes (#11445)
paulb777 Jun 15, 2023
c39dca7
[auth-swift] Refactor keychain implementation and tests (#11453)
paulb777 Jun 20, 2023
330ee81
Fix runtime warnings detected by Xcode 15 b3 (#11518)
paulb777 Jul 10, 2023
a2087fd
[auth-swift] Address a few todos (#11525)
paulb777 Jul 11, 2023
caea41a
[auth-swift] Rewrite Auth RPC types using Swift types (#11529)
paulb777 Jul 11, 2023
00bcca2
Post rebase style and other fixes
paulb777 Jul 12, 2023
d33ce7c
🚧 Add AsyncSequence for Auth
peterfriese Jul 14, 2023
6e00b72
🚧 AsyncSequences WIP
peterfriese Jul 14, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
8817084926B95A63009E9281 /* FirebaseFirestoreSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 8817084826B95A63009E9281 /* FirebaseFirestoreSwift */; };
88327B8826D62908002AA6D9 /* FavouriteFruitsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88327B8726D62908002AA6D9 /* FavouriteFruitsView.swift */; };
8844BA6126E0DD3F000786F0 /* FavouriteFruitsMappingErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8844BA6026E0DD3F000786F0 /* FavouriteFruitsMappingErrorView.swift */; };
887FEFE32A5574EB00FB2756 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 887FEFE22A5574EA00FB2756 /* GoogleService-Info.plist */; };
887FEFE52A5576FA00FB2756 /* FavouriteFruitsAsyncSequenceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 887FEFE42A5576FA00FB2756 /* FavouriteFruitsAsyncSequenceView.swift */; };
88D5E37826EBD2F200808AFF /* FavouriteFruitsMappingErrorView2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88D5E37726EBD2F200808AFF /* FavouriteFruitsMappingErrorView2.swift */; };
88D9354A2A39CB3E00FD8AFF /* FavouriteFruitsAnimationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88D935492A39CB3E00FD8AFF /* FavouriteFruitsAnimationView.swift */; };
88D9354C2A39D72300FD8AFF /* FirebaseAuth in Frameworks */ = {isa = PBXBuildFile; productRef = 88D9354B2A39D72300FD8AFF /* FirebaseAuth */; };
88E5A79A2A39DDE400462B64 /* FavouriteFruitsNoAnimationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88E5A7992A39DDE400462B64 /* FavouriteFruitsNoAnimationsView.swift */; };
88E5A79C2A39E11A00462B64 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 88E5A79B2A39E11A00462B64 /* GoogleService-Info.plist */; };
88FBD98826B9485F00982BF2 /* FirestoreSampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88FBD98726B9485F00982BF2 /* FirestoreSampleApp.swift */; };
88FBD98C26B9486100982BF2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 88FBD98B26B9486100982BF2 /* Assets.xcassets */; };
88FBD98F26B9486100982BF2 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 88FBD98E26B9486100982BF2 /* Preview Assets.xcassets */; };
Expand All @@ -26,10 +27,11 @@
8809D0AE26B9520B00DE7864 /* firebase-ios-sdk */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "firebase-ios-sdk"; path = ../..; sourceTree = "<group>"; };
88327B8726D62908002AA6D9 /* FavouriteFruitsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavouriteFruitsView.swift; sourceTree = "<group>"; };
8844BA6026E0DD3F000786F0 /* FavouriteFruitsMappingErrorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavouriteFruitsMappingErrorView.swift; sourceTree = "<group>"; };
887FEFE22A5574EA00FB2756 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
887FEFE42A5576FA00FB2756 /* FavouriteFruitsAsyncSequenceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavouriteFruitsAsyncSequenceView.swift; sourceTree = "<group>"; };
88D5E37726EBD2F200808AFF /* FavouriteFruitsMappingErrorView2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavouriteFruitsMappingErrorView2.swift; sourceTree = "<group>"; };
88D935492A39CB3E00FD8AFF /* FavouriteFruitsAnimationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FavouriteFruitsAnimationView.swift; sourceTree = "<group>"; };
88E5A7992A39DDE400462B64 /* FavouriteFruitsNoAnimationsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavouriteFruitsNoAnimationsView.swift; sourceTree = "<group>"; };
88E5A79B2A39E11A00462B64 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
88FBD98426B9485F00982BF2 /* FirestoreSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FirestoreSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
88FBD98726B9485F00982BF2 /* FirestoreSampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirestoreSampleApp.swift; sourceTree = "<group>"; };
88FBD98B26B9486100982BF2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -90,7 +92,7 @@
88FBD99526B948A100982BF2 /* App */,
88FBD99626B948A900982BF2 /* Views */,
88FBD98B26B9486100982BF2 /* Assets.xcassets */,
88E5A79B2A39E11A00462B64 /* GoogleService-Info.plist */,
887FEFE22A5574EA00FB2756 /* GoogleService-Info.plist */,
88FBD98D26B9486100982BF2 /* Preview Content */,
);
path = FirestoreSample;
Expand Down Expand Up @@ -120,6 +122,7 @@
88D5E37726EBD2F200808AFF /* FavouriteFruitsMappingErrorView2.swift */,
88E5A7992A39DDE400462B64 /* FavouriteFruitsNoAnimationsView.swift */,
88D935492A39CB3E00FD8AFF /* FavouriteFruitsAnimationView.swift */,
887FEFE42A5576FA00FB2756 /* FavouriteFruitsAsyncSequenceView.swift */,
88FBD99726B948E200982BF2 /* MenuView.swift */,
);
path = Views;
Expand Down Expand Up @@ -188,8 +191,8 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
88E5A79C2A39E11A00462B64 /* GoogleService-Info.plist in Resources */,
88FBD98F26B9486100982BF2 /* Preview Assets.xcassets in Resources */,
887FEFE32A5574EB00FB2756 /* GoogleService-Info.plist in Resources */,
88FBD98C26B9486100982BF2 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -206,6 +209,7 @@
88327B8826D62908002AA6D9 /* FavouriteFruitsView.swift in Sources */,
88D9354A2A39CB3E00FD8AFF /* FavouriteFruitsAnimationView.swift in Sources */,
88FBD98826B9485F00982BF2 /* FirestoreSampleApp.swift in Sources */,
887FEFE52A5576FA00FB2756 /* FavouriteFruitsAsyncSequenceView.swift in Sources */,
88D5E37826EBD2F200808AFF /* FavouriteFruitsMappingErrorView2.swift in Sources */,
8844BA6126E0DD3F000786F0 /* FavouriteFruitsMappingErrorView.swift in Sources */,
);
Expand Down
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()
}
}
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()
}
}
8 changes: 8 additions & 0 deletions Example/FirestoreSample/FirestoreSample/Views/MenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ struct MenuView: View {
Label("With Animations", systemImage: "shippingbox")
}
}
Section(header: Text("Async")) {
NavigationLink(destination: FavouriteFruitsAsyncSequenceView()) {
Label("AsyncSequence (Collection)", systemImage: "shippingbox")
}
NavigationLink(destination: FavouriteFruitView()) {
Label("AsyncSequence (Document)", systemImage: "shippingbox")
}
}
}
.listStyle(InsetGroupedListStyle())
.navigationTitle("Firestore")
Expand Down
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
Copy link
Contributor

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.

do {
if let result = try documentSnapshot?.data(as: T.self) {
continuation.yield(result)
}
} catch {
continuation.finish(throwing: error)
}
}

continuation.onTermination = { @Sendable _ in
listener.remove()
}
}
}
}
47 changes: 47 additions & 0 deletions Firestore/Swift/Source/AsyncAwait/Query+AsyncStream.swift
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()
}
}
}
}
Loading