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 associatedtype
s 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
Props
struct.Declaration
Swift
associatedtype PropsType
-
The type of your view controller’s
Actions
struct.Declaration
Swift
associatedtype ActionsType
-
Being
Connectable
means that you must have aconnection
instance.Declaration
Swift
var connection: Connection<AppStateType, PropsType, ActionsType> { get }
-
props
Extension 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
Connection
object: whenever a new ReSwift state is received by your connection, it uses yourmapStateToProps
function to convert it yourProps
struct and makes it available through this variable.Declaration
Swift
var props: PropsType { get set }
-
actions
Extension methodThis is what your view controller uses whenever it wants to trigger an action. The
Connection
manages this variable: it usesmapDispatchToActions
to call your store’s dispatch function the right way.Declaration
Swift
var actions: ActionsType { get set }