File tree Expand file tree Collapse file tree 4 files changed +34
-21
lines changed Expand file tree Collapse file tree 4 files changed +34
-21
lines changed Original file line number Diff line number Diff line change 1
1
# Unreleased
2
+ - [ feature] Added an ` addSnapshotsInSyncListener() ` method to
3
+ ` FIRFirestore ` that notifies you when all your snapshot listeners are
4
+ in sync with each other.
2
5
3
6
# v1.5.1
4
7
- [ fixed] Fixed a memory access error discovered using the sanitizers in Xcode
Original file line number Diff line number Diff line change 15
15
*/
16
16
17
17
#import " FIRFirestore.h"
18
- #import " FIRListenerRegistration.h"
19
18
20
19
#include < memory>
21
20
#include < string>
@@ -69,26 +68,6 @@ NS_ASSUME_NONNULL_BEGIN
69
68
70
69
- (const std::shared_ptr<util::AsyncQueue> &)workerQueue ;
71
70
72
- /* *
73
- * Attaches a listener for a snapshots-in-sync event. Server-generated
74
- * updates and local changes can affect multiple snapshot listeners.
75
- * The snapshots-in-sync event indicates that all listeners affected by
76
- * a given change have fired.
77
- *
78
- * NOTE: The snapshots-in-sync event only indicates that listeners are
79
- * in sync with each other, but does not relate to whether those
80
- * snapshots are in sync with the server. Use SnapshotMetadata in the
81
- * individual listeners to determine if a snapshot is from the cache or
82
- * the server.
83
- *
84
- * @param listener A callback to be called every time all snapshot
85
- * listeners are in sync with each other.
86
- * @return A FIRListenerRegistration object that can be used to remove the
87
- * listener.
88
- */
89
- - (id <FIRListenerRegistration>)addSnapshotsInSyncListener : (void (^)(void ))listener
90
- NS_SWIFT_NAME(addSnapshotsInSyncListener(_:));
91
-
92
71
@property (nonatomic , assign , readonly ) std::shared_ptr<api::Firestore> wrapped;
93
72
94
73
@property (nonatomic , assign , readonly ) const model::DatabaseId &databaseID;
Original file line number Diff line number Diff line change 16
16
17
17
#import < Foundation/Foundation.h>
18
18
19
+ #import " FIRListenerRegistration.h"
20
+
19
21
@class FIRApp;
20
22
@class FIRCollectionReference;
21
23
@class FIRDocumentReference;
@@ -208,6 +210,26 @@ NS_SWIFT_NAME(Firestore)
208
210
*/
209
211
- (void )waitForPendingWritesWithCompletion:(void (^)(NSError *_Nullable error))completion;
210
212
213
+ /* *
214
+ * Attaches a listener for a snapshots-in-sync event. Server-generated
215
+ * updates and local changes can affect multiple snapshot listeners.
216
+ * The snapshots-in-sync event indicates that all listeners affected by
217
+ * a given change have fired.
218
+ *
219
+ * NOTE: The snapshots-in-sync event only indicates that listeners are
220
+ * in sync with each other, but does not relate to whether those
221
+ * snapshots are in sync with the server. Use SnapshotMetadata in the
222
+ * individual listeners to determine if a snapshot is from the cache or
223
+ * the server.
224
+ *
225
+ * @param listener A callback to be called every time all snapshot
226
+ * listeners are in sync with each other.
227
+ * @return A FIRListenerRegistration object that can be used to remove the
228
+ * listener.
229
+ */
230
+ - (id <FIRListenerRegistration>)addSnapshotsInSyncListener:(void (^)(void ))listener
231
+ NS_SWIFT_NAME (addSnapshotsInSyncListener(_:));
232
+
211
233
#pragma mark - Terminating
212
234
213
235
/* *
Original file line number Diff line number Diff line change @@ -66,6 +66,8 @@ func main() {
66
66
67
67
waitForPendingWrites ( database: db)
68
68
69
+ addSnapshotsInSyncListener ( database: db)
70
+
69
71
terminateDb ( database: db)
70
72
}
71
73
@@ -462,6 +464,13 @@ func waitForPendingWrites(database db: Firestore) {
462
464
}
463
465
}
464
466
467
+ func addSnapshotsInSyncListener( database db: Firestore ) {
468
+ let listener = db. addSnapshotsInSyncListener { }
469
+
470
+ // Unsubscribe
471
+ listener. remove ( )
472
+ }
473
+
465
474
func terminateDb( database db: Firestore ) {
466
475
db. terminate { error in
467
476
if let e = error {
You can’t perform that action at this time.
0 commit comments