Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Set.store(_:) AnyCancellable-constrained storage overloads. #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

Conversation

jasdev
Copy link
Member

@jasdev jasdev commented Apr 11, 2020

Figured it’d be helpful to have an anlog to the DisposeBag.insert(_:) variants.

@codecov
Copy link

codecov bot commented Apr 11, 2020

Codecov Report

Merging #21 into master will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #21      +/-   ##
==========================================
+ Coverage   96.72%   96.78%   +0.05%     
==========================================
  Files          34       36       +2     
  Lines        1617     1646      +29     
==========================================
+ Hits         1564     1593      +29     
  Misses         53       53              
Impacted Files Coverage Δ
Sources/Utilities/Set+AnyCancellable.swift 100.00% <100.00%> (ø)
Tests/Set+AnyCancellableTests.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 7ed4677...54de830. Read the comment docs.

@freak4pc
Copy link
Member

Hey @jasdev - thanks for this :) In this specific case though, I think this PR doesn't really fit the spirit of CombineExt, because this extension effects Set as a whole and only allows really light ergonomics.

The more "generic" version of this would allow set.insert(contentsOf: [...]), which is a behavior you can get if you use an Array<AnyCancellable>, instead.

I don't think this specific extension is useful enough to include here and am more worried about the fact it extends a Foundation type, and not a Combine type.

WDYT?

@jasdev
Copy link
Member Author

jasdev commented Apr 13, 2020

because this extension effects Set as a whole

For what it’s worth, it is constrained to Set.Element == AnyCancellable. So, its surface area is as small as possible.

which is a behavior you can get if you use an Array<AnyCancellable>, instead.

Yep! Multi-inserting isn’t available on Set and I figured the cosmetic is worth it so folks don’t have to fall back for an Array when a Set might be more performant in handling accidental double-inserts of the same cancellable.

it extends a Foundation type, and not a Combine type.

While true, it again is constrained to a Combine type. So it’s only surfaced to folks working with Set<AnyCancellable>s.


I don’t have a strong opinion here though, so, if you’re not digging it I’m totally cool closing this. 😄

@freak4pc
Copy link
Member

It feels wrong to add, in my eyes. I might've extended this on a personal project but I'm feeling weird adding an extension on Set for a project around Combine extensions and operators, especially since it's quite simple and would be trivial to write yourself if its ergonomics you're interested in having.

I think that the way to go would be to find more people who think this is a good addition to have as part of CombineExt, in which case we can add this, but otherwise I'd prefer to leave it out.

@jasdev
Copy link
Member Author

jasdev commented Apr 17, 2020

10-4!

@jasdev jasdev closed this Apr 17, 2020
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