Skip to content

Commit 6bcf6ba

Browse files
authored
publish waitForPendingWrites (#3690)
* publish waitForPendingWrites * add change log * move impl out of internal
1 parent 7870c73 commit 6bcf6ba

File tree

4 files changed

+23
-20
lines changed

4 files changed

+23
-20
lines changed

Firestore/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
- [changed] Transactions now perform exponential backoff before retrying.
33
This means transactions on highly contended documents are more likely to
44
succeed.
5+
- [feature] Added a `waitForPendingWrites()` method to `FIRFirestore` class
6+
which allows users to wait on a promise that resolves when all pending
7+
writes are acknowledged by the Firestore backend.
58

69
# v1.4.5
710
- [fixed] Fixed a crash that would happen when changing networks or going from

Firestore/Source/API/FIRFirestore+Internal.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,6 @@ NS_ASSUME_NONNULL_BEGIN
9090

9191
- (void)shutdownInternalWithCompletion:(nullable void (^)(NSError *_Nullable error))completion;
9292

93-
/**
94-
* Waits until all currently pending writes for the active user have been acknowledged by the
95-
* backend.
96-
*
97-
* The completion block is called immediately without error if there are no outstanding writes.
98-
* Otherwise, the completion block is called when all previously issued writes (including those
99-
* written in a previous app session) have been acknowledged by the backend. The completion
100-
* block does not wait for writes that were added after the method is called. If you
101-
* wish to wait for additional writes, you have to call `waitForPendingWritesWithCompletion`
102-
* again.
103-
*
104-
* Any outstanding `waitForPendingWritesWithCompletion` completion blocks are called with an
105-
* error during user change.
106-
*/
107-
- (void)waitForPendingWritesWithCompletion:(void (^)(NSError *_Nullable error))completion;
108-
10993
- (const std::shared_ptr<util::AsyncQueue> &)workerQueue;
11094

11195
@property(nonatomic, assign, readonly) std::shared_ptr<api::Firestore> wrapped;

Firestore/Source/API/FIRFirestore.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ - (void)clearPersistenceWithCompletion:(nullable void (^)(NSError *_Nullable err
277277
_firestore->ClearPersistence(util::MakeCallback(completion));
278278
}
279279

280+
- (void)waitForPendingWritesWithCompletion:(void (^)(NSError *_Nullable error))completion {
281+
_firestore->WaitForPendingWrites(util::MakeCallback(completion));
282+
}
283+
280284
@end
281285

282286
@implementation FIRFirestore (Internal)
@@ -314,10 +318,6 @@ - (void)shutdownWithCompletion:(nullable void (^)(NSError *_Nullable error))comp
314318
[self shutdownInternalWithCompletion:completion];
315319
}
316320

317-
- (void)waitForPendingWritesWithCompletion:(void (^)(NSError *_Nullable error))completion {
318-
_firestore->WaitForPendingWrites(util::MakeCallback(completion));
319-
}
320-
321321
@end
322322

323323
NS_ASSUME_NONNULL_END

Firestore/Source/Public/FIRFirestore.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,22 @@ NS_SWIFT_NAME(Firestore)
192192
*/
193193
- (void)clearPersistenceWithCompletion:(nullable void (^)(NSError *_Nullable error))completion;
194194

195+
/**
196+
* Waits until all currently pending writes for the active user have been acknowledged by the
197+
* backend.
198+
*
199+
* The completion block is called immediately without error if there are no outstanding writes.
200+
* Otherwise, the completion block is called when all previously issued writes (including those
201+
* written in a previous app session) have been acknowledged by the backend. The completion
202+
* block does not wait for writes that were added after the method is called. If you
203+
* wish to wait for additional writes, you have to call `waitForPendingWritesWithCompletion`
204+
* again.
205+
*
206+
* Any outstanding `waitForPendingWritesWithCompletion` completion blocks are called with an
207+
* error during user change.
208+
*/
209+
- (void)waitForPendingWritesWithCompletion:(void (^)(NSError *_Nullable error))completion;
210+
195211
@end
196212

197213
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)