Functions
The following functions are available globally.
-
The combination between two
AfterReducer
instances occur in reverse order so the first middleware will have its “after reducer” closure executed last. This composition can be achieved by using the operator<>
.Declaration
Swift
@available(*, deprecated, message: "Use `MiddlewareProtocol` instead of `Middleware`. It doesn't use `AfterReducer`. This operator will be removed on 1.0.") public func <> (lhs: AfterReducer, rhs: AfterReducer) -> AfterReducer
-
Initializes a
ComposedMiddleware
from thelhs
andrhs
middlewares parameters, or appends to thelhs
if it is already aComposedMiddleware
, as shown below:let composedOfThreeMiddlewares = composedOfTwoMiddlewares <> thirdMiddleware
Or
let composedOfThreeMiddlewares = firstMiddleware <> secondMiddleware <> thirdMiddleware
Or
let composedMiddlewares = firstMiddleware <> secondMiddleware _ = composedMiddlewares <> thirdMiddleware // assert(composedMiddlewares == firstMiddleware <> secondMiddleware <> thirdMiddleware)
Declaration
Swift
public func <> <M1: MiddlewareProtocol, M2: MiddlewareProtocol>(lhs: M1, rhs: M2) -> ComposedMiddleware<M1.InputActionType, M1.OutputActionType, M1.StateType> where M1.InputActionType == M2.InputActionType, M1.OutputActionType == M2.OutputActionType, M1.StateType == M2.StateType
Parameters
lhs
A flat middleware or a composed middleware, in case it’s a flat one, this operation will create a new
ComposedMiddleware
and return it, otherwise it will append therhs
to this composed lhs one mutating it and also returning it.rhs
A flat middleware to be appended to the end of a
ComposedMiddleware
Return Value
A
ComposedMiddleware
that calls thelhs
methods before therhs
ones. Iflhs
is already aComposedMiddleware
, we will return the same instance after mutating it to have therhs
in the end of its chain.