Connectable
public protocol Connectable
Declare your view controller to be suitable for ReRxSwift. This requires your
view controller to add a Connection property. Please note that you do not need
to explicitly specify what the associatedtypes are in your case, the compiler
will derive this from the parameters to the
Connection(store:mapStateToProps:mapDispatchToProps) constructor.
Example:
class MyViewController: UIViewController {
let connection = Connection(
store: store,
mapStateToProps: mapStateToProps,
mapDispatchToActions: mapDispatchToActions
)
...
-
The type of your global ReSwift application state.
Declaration
Swift
associatedtype AppStateType : StateType -
The type of your view controller’s
Propsstruct.Declaration
Swift
associatedtype PropsType -
The type of your view controller’s
Actionsstruct.Declaration
Swift
associatedtype ActionsType -
Being
Connectablemeans that you must have aconnectioninstance.Declaration
Swift
var connection: Connection<AppStateType, PropsType, ActionsType> { get } -
propsExtension methodThis is what your view controller uses to access the state that it wants to use. The contents of this variable is managed by the
Connectionobject: whenever a new ReSwift state is received by your connection, it uses yourmapStateToPropsfunction to convert it yourPropsstruct and makes it available through this variable.Declaration
Swift
var props: PropsType { get set } -
actionsExtension methodThis is what your view controller uses whenever it wants to trigger an action. The
Connectionmanages this variable: it usesmapDispatchToActionsto call your store’s dispatch function the right way.Declaration
Swift
var actions: ActionsType { get set }
View on GitHub
Connectable Protocol Reference