AnyActionHandler
public struct AnyActionHandler<ActionType> : ActionHandler
ActionHandler defines a protocol for entities able to handle actions - defined by the associated type ActionType
and AnyActionHandler erases this protocol to a generic struct type.
The only protocol requirement is a function that allows other entities to dispatch actions, so Views (or Presenters, ViewModels) in your UI layer, or even Middlewares can create actions of a certain type and send to your store, that is generalized by this protocol.
-
Erases the provided
ActionHandlerby using its inner methods from this wrapperDeclaration
Swift
public init<A>(_ realHandler: A) where ActionType == A.ActionType, A : ActionHandlerParameters
realHandlerthe concrete
ActionHandleryou’re erasing -
Erases the any type that implements the
dispatchfunction to act as aActionHandlerDeclaration
Swift
public init(_ realHandler: @escaping (DispatchedAction<ActionType>) -> Void)Parameters
realHandlera function with the same signature of
ActionHandler.dispatch -
The function that allows Views, ViewControllers, Presenters to dispatch actions to the store. Also way for a
Middlewareto trigger their own actions, usually in response to events or async operations.Declaration
Swift
public func dispatch(_ dispatchedAction: DispatchedAction<ActionType>)Parameters
dispatchedActionstruct holding the action (action to be dispatched) + dispatcher (information about the action source, containing file/line, function and additional information for debugging and logging purposes)
View on GitHub
AnyActionHandler Structure Reference