File tree Expand file tree Collapse file tree
Sources/SHFirestoreService Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,7 +14,26 @@ import Combine
1414@available ( swift 5 . 0 )
1515@available ( iOS 13 . 0 , * )
1616
17- extension Publisher where Output == WriteBatch , Failure == FirestoreServiceError {
17+ public extension Publisher where Output == WriteBatch , Failure == FirestoreServiceError {
18+
19+ /// This is an extension function used to commit WriteBatches.
20+ ///
21+ /// Notes:
22+ /// 1. Generate and return a WriteBatch from the upstream publihser's output value.
23+ /// 2. Perform to commit batch using tins func
24+ ///
25+ /// Examples:
26+ /// ```
27+ /// # using the batch and commit functions when deleting an entire document #
28+ /// let collectionRef = ... # Get CollectionReference..
29+ /// let subscription = collectionRef.getDocuments().map { snapshot in
30+ /// let batch = Firestore.firestore().batch()
31+ /// snapshot.documents.forEach { batch.deleteDocument($0.reference) }
32+ /// return batch
33+ /// }
34+ /// .commit() # perform commit from upstream's a batch : ]
35+ /// # downstream
36+ /// ```
1837 func commit( ) -> AnyPublisher < Void , Failure > {
1938 return self . flatMap { batch in
2039 return batch
You can’t perform that action at this time.
0 commit comments