Skip to content

Commit c69dff8

Browse files
committed
[Style] Comment example about commit() in Combine+WriteBatch.swift
1 parent c4836ee commit c69dff8

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

Sources/SHFirestoreService/Combine+WriteBatch.swift

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)