Combine and SwiftUI additions
New Features/Enhancements
-
Add
ActionProtocol
-
Add
AnyAction
, allowing to type-erase any actions represented by aActionProtocol
-
Add
CoalescingAction
&OverridingAction
-
Add a
CombineExtensions
&CombineExtensionsProvider
protocol, replicating the.reactive
of ReactiveSwift (so as not to pollute too much the global namespace) -
All
NSObject
now can have acancellables
object attached to them via<object>.combineExtensions.cancellables
. It's created lazily, so there's impact if not used. -
Extend
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 received
-
Add
Publisher.promoteOptional()
-
Add
then(receiveResult:)
, which takes a closure with aResult
, allowing to handle values & error in the same place -
Add
sinkForLifetimeOf(_:)
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). -
Add
performDuringLifetimeOf(_:action:)
, allowing to link an action with the lifetime of an object. This act as an equivalent formakeBindingTarget
fromReactiveSwift
when calling functions or assigning multiple variables. -
Add
assign(to:forLifetimeOf:)
, allowing to assign the output of the producer to a keyPath, keeping it alive until the specified object is deallocated. -
Add
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) -
Add
<UIControl>.publisherForControlEvent(_:)
, to get a publisher that triggers on any control events. -
Add
(UITextField/UITextView).(textValues|continuousTextValues)
, which are equivalent to same thing as for ReactiveCocoa.
Stéphane Copin
#54 -
Add an optional
insets
parameter toaddAndFitSubview()
-
Make
removeArrangedSubviews()
'sremoveFromHierachy
parameter default totrue
-
Add
tapped
helper to link anyReactiveActionProtocol
to anyUIControl
-
Add
AnyIdentifiable
&AnyAction
for type-erasedIdentifiable
&ReactiveActionProtocol
respectively -
Add
OverridingAction
, a newAction
that if executed when already executing, will cancel the previous producer and start a new one -
Make
OrderedSet
conform toSetAlgebra
Stéphane Copin
#53
Bug Fixes
-
Fix a bug in
CombineLatestMany
where cancelling the resulting publisher would not cancel the array of publishers themselves.
Stéphane Copin
#55 -
Fix a bug in
Action
where a cancellation would be ignored and not setisExecuting
tofalse
Stéphane Copin
#54 -
Fix an internal state corruption issue in
OrderedSet
Stéphane Copin
#53
Breaking changes
- The original
TapAction
,OverridingAction
andAnyAction
were all prefixed withReactive
.
Stéphane Copin
#54