-
Notifications
You must be signed in to change notification settings - Fork 11
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
Feat/combine additions #54
Conversation
eb16001
to
947344d
Compare
2358901
to
98393f3
Compare
Codecov Report
@@ Coverage Diff @@
## develop #54 +/- ##
===========================================
+ Coverage 7.34% 12.00% +4.65%
===========================================
Files 60 71 +11
Lines 1729 2033 +304
===========================================
+ Hits 127 244 +117
- Misses 1602 1789 +187
Continue to review full report at Codecov.
|
784900a
to
dd6d3cd
Compare
dd6d3cd
to
fa57348
Compare
6748510
to
e27e236
Compare
fa57348
to
a43ee72
Compare
e27e236
to
6fc6b8a
Compare
a43ee72
to
2a70436
Compare
6fc6b8a
to
6963623
Compare
2a70436
to
010504b
Compare
6963623
to
29be1b6
Compare
010504b
to
8bedb52
Compare
8bedb52
to
588a141
Compare
44e6c2e
to
588a141
Compare
44e6c2e
to
588a141
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks solid! And the amount of documentation provided is a nice to have 👍
Goals ⚽
This PRs add a substantial amount of Combine helper, and adds a
CombineUIKit
new subspec that aims to provide a similar level of helpers asReactiveCocoa
did.A
smallsummary of the changes (the following changes relates to Combine):Action
where a cancellation would be ignored and not setisExecuting
tofalse
ActionProtocol
AnyAction
, allowing to type-erase any actions represented by aActionProtocol
CoalescingAction
&OverridingAction
CombineExtensions
&CombineExtensionsProvider
protocol, replicating the.reactive
of ReactiveSwift (so as not to pollute too much the global namespace)NSObject
now can have acancellables
object attached to them via<object>.combineExtensions.cancellables
. It's created lazily, so there's impact if not used.Publisher.handleEvents
to add two new hooks:receiveTermination
: When either a completion or a cancellation is receivedreceiveResult
: Takes aResult
, and called when either values are received or an error is receivedPublisher.promoteOptional()
then(receiveResult:)
, which takes a closure with aResult
, allowing to handle values & error in the same placesinkForLifetimeOf(_:)
methods family, allowing to sink on a publisher and link to the lifetime of a givenCombineExtensionsProvider & AnyObject
. The goal of this is to avoid having to write the classic boilerplate code in Combine handling with having to createcancellables
for every single object (this used thecancellables
extension mentioned above).performDuringLifetimeOf(_:action:)
, allowing to link an action with the lifetime of an object. This act as an equivalent formakeBindingTarget
when calling functions or assigning multiple variables, for example:becomes:
In usage, it's a bit different as well:
becomes
For assigning a single variable, see below.
assign(to:forLifetimeOf:)
, allowing to assign the output of the producer to a keyPath, keeping it alive until the specified object is deallocated. For example:Becomes
TapAction
and<UIControl>.combineExtensions.tapped
, allowing to link anAction
to a button, without having to do the bindings manually (similar toUIButton.reactive.pressed
in ReactiveCocoa)<UIControl>.publisherForControlEvent(_:)
, to get a publisher that triggers on any control events.(UITextField/UITextView).(textValues|continuousTextValues)
, which are equivalent to same thing as for ReactiveCocoa.Backwards-compatibility:
The original
TapAction
,OverridingAction
andAnyAction
were all prefixed withReactive
.I'm looking forward to getting some feedback, about anything (naming, helpers, how it's done, why it's done, etc)! The goal here is to make programming with Combine when using
UIKit
as nice as working with theReactiveSwift
/ReactiveCocoa
combo.Depends on #53