Middleware
public protocol Middleware
Extends the store functionality by providing a middle layer between dispatched actions and the store’s reducer.
Before an action is given to a reducer, middleware have an opportunity to handle it themselves. They may dispatch their own actions, transform the current action, or block it entirely.
Middleware can also be used to set up external hooks from services.
-
Undocumented
Declaration
Swift
associatedtype State -
Perform any middleware actions within this function.
Declaration
Swift
func run(store: StoreProxy<State>, action: Action) -> Action?Parameters
storeThe store object. Use
store.nextwhen the middleware is complete.actionThe latest dispatched action to process.
Return Value
An optional action to pass to the next middleware.
-
compile(store:Default implementation) Compiles the middleware into a SendAction closure.
Default Implementation
Declaration
Swift
func compile(store: StoreProxy<State>) -> SendActionParameters
storeA reference to the store used by the middleware.
Return Value
The SendAction that performs the middleware.
-
callAsFunction(store:Extension method) Apply the middleware to a store proxy.
Declaration
Swift
@inlinable public func callAsFunction(store: StoreProxy<State>) -> SendActionParameters
storeThe store proxy.
Return Value
A SendAction function that performs the middleware for the provided store proxy.
View on GitHub
Middleware Protocol Reference