Skip to content

Conversation

troupmar
Copy link
Contributor

@troupmar troupmar commented Mar 22, 2022

FlatMapFirst operator is a special case of flatMap operator.

Like FlatMapLatest, it only allows one inner publisher at a time. Unlike FlatMapLatest, 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:

@troupmar troupmar mentioned this pull request Mar 22, 2022
@troupmar troupmar changed the title Implementation of flatMapFirst operator Implementation of FlatMapFirst operator Mar 22, 2022
isRunning = newValue
}

return self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting idea for an implementation! Also seems like a good test suite to cover it.
Can you remove the explicit self here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it should be gone...

@troupmar troupmar force-pushed the feature/flat-map-first branch from 5d116e5 to 88c7425 Compare April 4, 2022 09:37
Copy link
Member

@freak4pc freak4pc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for taking so long! I'd like to merge this, just a quick note on the test naming and we can go ahead. @troupmar

If you don't have the time let me know and I'll do my best to take care of it myself.

XCTAssertTrue(isUpstreamCompleted)
}

func test_flatMapFirst_error_upstream_skipping_flatMap() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it renamed!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems likje a minor conflict to fix and then we can merge :) thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, sorry. I resolved it.

@troupmar troupmar force-pushed the feature/flat-map-first branch from 3b328b3 to 2b1b328 Compare July 25, 2022 08:51
@freak4pc
Copy link
Member

Still conflicted @troupmar :)

@troupmar troupmar force-pushed the feature/flat-map-first branch from 2b1b328 to 78c0db4 Compare July 27, 2022 12:59
@troupmar
Copy link
Contributor Author

troupmar commented Jul 27, 2022

There were new conflicts introduced, I guess. But I resolved them as well! Still waiting for "1 workflow awaiting approval" ;)

@codecov
Copy link

codecov bot commented Jul 27, 2022

Codecov Report

Merging #119 (78c0db4) into main (047d9bc) will decrease coverage by 0.05%.
The diff coverage is 93.00%.

@@            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     
Impacted Files Coverage Δ
Sources/Operators/FlatMapFirst.swift 90.00% <90.00%> (ø)
Tests/FlatMapFirstTests.swift 93.75% <93.75%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 047d9bc...78c0db4. Read the comment docs.

@freak4pc freak4pc merged commit 1f6b0df into CombineCommunity:main Jul 27, 2022
@freak4pc
Copy link
Member

Thank you!

@troupmar
Copy link
Contributor Author

Thanks for the assist! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants