Skip to content

Commit 36b8db5

Browse files
jasdevfreak4pc
authored andcommitted
s/predicate/comparator for all occurrences related to .removeAllDuplicates.
1 parent 6ef9dfa commit 36b8db5

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ intArrayPublisher.send([10, 2, 2, 4, 3, 8])
407407

408408
`Publisher.removeAllDuplicates` and `.removeAllDuplicates(by:)` are stricter forms of Apple’s [`Publisher.removeDuplicates`](https://developer.apple.com/documentation/combine/publisher/3204745-removeduplicates) and [`.removeDuplicates(by:)`](https://developer.apple.com/documentation/combine/publisher/3204746-removeduplicates)—the operators de-duplicate across _all_ previous value events, instead of pairwise.
409409

410-
If your `Output` doesn‘t conform to `Hashable` or `Equatable`, you may instead use the predicate-based version of this operator to decide whether two elements are equal.
410+
If your `Output` doesn‘t conform to `Hashable` or `Equatable`, you may instead use the comparator-based version of this operator to decide whether two elements are equal.
411411

412412
```swift
413413
subscription = [1, 1, 2, 1, 3, 3, 4].publisher

Sources/Operators/RemoveAllDuplicates.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public extension Publisher where Output: Equatable {
3636
}
3737

3838
public extension Publisher {
39-
/// De-duplicates _all_ published value events, along the provided `by` predicate, as opposed to pairwise with `Publisher.removeDuplicates(by:)`.
39+
/// De-duplicates _all_ published value events, along the provided `by` comparator, as opposed to pairwise with `Publisher.removeDuplicates(by:)`.
4040
///
41-
/// - parameter by: A predicate to use when determining uniqueness. `Publisher.removeAllDuplicates` will iterate
42-
/// over all seen values applying each known unique value as the first argument to the predicate and the
43-
/// incoming value event as the second, i.e. `by(see, next) -> Bool`. If this predicate is `true` for any
41+
/// - parameter by: A comparator to use when determining uniqueness. `Publisher.removeAllDuplicates` will iterate
42+
/// over all seen values applying each known unique value as the first argument to the comparator and the
43+
/// incoming value event as the second, i.e. `by(see, next) -> Bool`. If this comparator is `true` for any
4444
/// seen value, the next incoming value isn’t emitted downstream.
4545
///
4646
/// - note: It’s important to note that this operator stores all emitted values

Tests/RemoveAllDuplicatesTests.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ final class RemoveAllDuplicatesTests: XCTestCase {
167167
XCTAssertEqual(completion, .failure(.anError))
168168
}
169169

170-
// MARK: - Predicate-related tests
170+
// MARK: - Comparator-related tests
171171

172172
private let isMultipleOf: (Int, Int) -> Bool = { seen, incoming in incoming.isMultiple(of: seen) }
173173

174-
func testPredicateExpectedDeduplication() {
174+
func testComparatorExpectedDeduplication() {
175175
var results = [Int]()
176176

177177
subscription = [2, 3, 3, 4].publisher
@@ -181,7 +181,7 @@ final class RemoveAllDuplicatesTests: XCTestCase {
181181
XCTAssertEqual(results, [2, 3])
182182
}
183183

184-
func testPredicateDeduplicationWithNoDuplicates() {
184+
func testComparatorDeduplicationWithNoDuplicates() {
185185
var results = [Int]()
186186

187187
subscription = [3, 5, 7, 11].publisher
@@ -191,7 +191,7 @@ final class RemoveAllDuplicatesTests: XCTestCase {
191191
XCTAssertEqual(results, [3, 5, 7, 11])
192192
}
193193

194-
func testPredicateDeduplicationDoesntInterfereWithFinishEvents() {
194+
func testComparatorDeduplicationDoesntInterfereWithFinishEvents() {
195195
let integers = PassthroughSubject<Int, Never>()
196196

197197
var completion: Subscribers.Completion<Never>?
@@ -211,7 +211,7 @@ final class RemoveAllDuplicatesTests: XCTestCase {
211211
XCTAssertEqual(completion, .finished)
212212
}
213213

214-
func testPredicateDeduplicationDoesntInterfereWithErrorEvents() {
214+
func testComparatorDeduplicationDoesntInterfereWithErrorEvents() {
215215
let integers = PassthroughSubject<Int, RemoveAllDuplicatesTestError>()
216216

217217
var completion: Subscribers.Completion<RemoveAllDuplicatesTestError>?

0 commit comments

Comments
 (0)