CombineCommunity / CombineExt

CombineExt provides a collection of operators, publishers and utilities for Combine, that are not provided by Apple themselves, but are common in other Reactive Frameworks and standards.
https://combine.community
MIT License
1.73k stars 155 forks source link

Make WithLatestFrom transparently CompactMap #83

Closed b8591340 closed 3 years ago

b8591340 commented 3 years ago

It leverages Sink.TransformOutput‘s signature to merely “forward” the optional through ResultSelector.

Not sure if WithLatestFrom is supposed to drop nil values from AnyPublisher<Optional<Int>, Never>. If it is this merely compacts within the result selector as well. If not then it‘s a bug due to the way the sink‘s transformOutput returns the resultSelector and it needs to be addressed, and a compacting WithLatestFrom, if welcome, would likely need to be an operator by itself.

codecov[bot] commented 3 years ago

Codecov Report

Merging #83 (1c592e0) into main (5b8a0c0) will increase coverage by 0.05%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #83      +/-   ##
==========================================
+ Coverage   97.01%   97.07%   +0.05%     
==========================================
  Files          60       60              
  Lines        3215     3280      +65     
==========================================
+ Hits         3119     3184      +65     
  Misses         96       96              
Impacted Files Coverage Δ
Sources/Operators/WithLatestFrom.swift 93.33% <100.00%> (+0.18%) :arrow_up:
Tests/WithLatestFromTests.swift 100.00% <100.00%> (ø)

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 5b8a0c0...1c592e0. Read the comment docs.

b8591340 commented 3 years ago

Well, it seems I might have had the failing test case in this branch.

I‘ll close, but if a flattening withLatestFrom is still welcome I‘ll look into implementing it myself. Thanks for the swift reply and sorry for the noise. Great work with the library, withLatestFrom itself is essential. Thank you!