A 1:1 port of ReactorKit using Combine instead of RxSwift. Also includes some basic extensions for working with SwiftUI.
Combiners are state machines which take in Actions and produce States which can be bound to UI elements in UIViewControllers or SwiftUI views.
This allows an implementation of unidirectional architecture, where inputs from the UI go into the Combiner to produce outputs of state changes.
Using a Combiner first requires creating a subclass of
Combiner. The subclass must create an associated type for
State which is the view state represented by the Combiner. It also must create an
Action associated type, usually declared as an enum, which defines all the inputs the Combiner will get from the view. Next, the internal
Mutation is associated as well, again usually as an enum. The
Mutation type defines the operations that can be made to the
State and very often, but not necessarily, is 1:1 with properties of the
After these types are declared, the following functions are required to be implemented:
func mutate(action: Action) -> AnyPublisher<Mutation, Never>
func reduce(state: State, mutation: Mutation) -> State
state property is available on the combiner to observe and bind to changes to the view.
For more information, please check out the ReactorKit repo since almost all implementation details apply to this port.
|Last commit: 4 weeks ago|
This release improves thread handling when updating the current state which helps with SwiftUI data flow.