Implementation of FlatMapFirst operator#119
Conversation
Sources/Operators/FlatMapFirst.swift
Outdated
| isRunning = newValue | ||
| } | ||
|
|
||
| return self |
There was a problem hiding this comment.
Interesting idea for an implementation! Also seems like a good test suite to cover it.
Can you remove the explicit self here?
There was a problem hiding this comment.
Sure, it should be gone...
5d116e5 to
88c7425
Compare
Tests/FlatMapFirstTests.swift
Outdated
| XCTAssertTrue(isUpstreamCompleted) | ||
| } | ||
|
|
||
| func test_flatMapFirst_error_upstream_skipping_flatMap() { |
There was a problem hiding this comment.
Can we change the naming to not use underscores?
I believe that's not really common practice in Swift.
Could also be a bit denser. Since we are in flatMapFirstTests, there's no need for test_flatMapFirst prefix. You can just call it testErrorSkipsFlatmap, or however you'd like. (This applies to the other tests too)
There was a problem hiding this comment.
seems likje a minor conflict to fix and then we can merge :) thank you.
There was a problem hiding this comment.
My bad, sorry. I resolved it.
3b328b3 to
2b1b328
Compare
|
Still conflicted @troupmar :) |
2b1b328 to
78c0db4
Compare
|
There were new conflicts introduced, I guess. But I resolved them as well! Still waiting for "1 workflow awaiting approval" ;) |
Codecov Report
@@ Coverage Diff @@
## main #119 +/- ##
==========================================
- Coverage 95.51% 95.45% -0.06%
==========================================
Files 70 72 +2
Lines 4166 4266 +100
==========================================
+ Hits 3979 4072 +93
- Misses 187 194 +7
Continue to review full report at Codecov.
|
|
Thank you! |
|
Thanks for the assist! :) |
FlatMapFirstoperator is a special case offlatMapoperator.Like
FlatMapLatest, it only allows one inner publisher at a time. UnlikeFlatMapLatest, it will not cancel an ongoing inner publisher.Instead it ignores events from the source until the inner publisher is done. It creates another inner publisher only when the previous one is done.
Sources: