Middleware

public struct Middleware<State>

Middleware is a structure that allows you to modify, filter out and dispatch more actions, before the action being handled reaches the store.

  • Create a blank slate Middleware.

    Declaration

    Swift

    public init()
  • Initialises the middleware by concatenating the transformative functions from the middleware that was passed in.

    Declaration

    Swift

    public init(_ first: Middleware<State>, _ rest: Middleware<State>...)
  • Safe encapsulation of side effects guaranteed not to affect the action being passed through the middleware.

    Declaration

    Swift

    public func sideEffect(_ effect: @escaping (GetState, @escaping DispatchFunction, Action) -> Void) -> Middleware<State>
  • Concatenates the transform function of the passed Middleware onto the callee’s transform.

    Declaration

    Swift

    public func concat(_ other: Middleware<State>) -> Middleware<State>
  • Transform the action into another action.

    Declaration

    Swift

    public func map(_ transform: @escaping (GetState, Action) -> Action) -> Middleware<State>
  • Undocumented

    Declaration

    Swift

    public struct Middleware<State>
  • One to many pattern allowing one action to be turned into multiple.

    Declaration

    Swift

    public func flatMap(_ transform: @escaping (GetState, Action) -> [Action]) -> Middleware<State>
  • Filters while mapping actions to new actions.

    Declaration

    Swift

    public func flatMap(_ transform: @escaping (GetState, Action) -> Action?) -> Middleware<State>
  • Drop the action iff isIncluded(action) != true.

    Declaration

    Swift

    public func filter(_ isIncluded: @escaping (GetState, Action) -> Bool) -> Middleware<State>