Type Aliases

The following type aliases are available globally.

  • Typealias for the function that is invoked to continue with the interceptors chains.

    Declaration

    Swift

    public typealias StoreInterceptorNext = (Dispatchable) throws -> Void
  • An interceptor is like a catch-all system that can be used to implement functionalities such as logging, or to dynamically change the behaviour of the store. An interceptor is invoked every time something has been dispatched and it is about to be handled.

    Initialization

    When the store is initialised, the first closure is invoked and the interceptor receives the context passed to the side effects. The interceptor can later use this context to retrieve the state or to dispatch new items.

    This step is performed once in the store lifetime.

    Receiving Next

    When the dispatchable is about to be handled, the store invokes the second function and passes next to the interceptor. Next is a generic way to pass the next step of the interceptors chaining.

    The interceptor should save this value and use it in the next step.

    This step is performed multiple times in the store lifetime, once for each dispatchable item handled by the store.

    Receiving the dispatchable

    Before handling the dispatchable (e.g., update the state in case of a StateUpdater). The last closure is invoked.

    Here the interceptor can do anything it needs to in order to implement the desired behaviour. Eventually, though, it should either invoke next passing the dispatchable (that is, the chain continues) or throw an error, which will reject the related promise and will make so that the operation related to the dispatchable is not performed.

    The next method can be also invoked with a different dispatchable with respect to the received one.

    This step is performed multiple times in the store lifetime, once for each dispatchable item handled by the store.

    Declaration

    Swift

    public typealias StoreInterceptor =
      (_ sideEffectContext: AnySideEffectContext) ->
      (_ next: @escaping StoreInterceptorNext) ->
      (_ dispatchable: Dispatchable) throws -> Void
  • Typealias for the function that is invoked when the state changes.

    Declaration

    Swift

    public typealias AnyStoreListener = (_ oldState: State, _ newState: State) -> Void

    Parameters

    oldState

    the state before the update

    newState

    the state after the update

  • Typealias for the function that is invoked when the state changes.

    Declaration

    Swift

    public typealias StoreListener<S> = (_ oldState: S, _ newState: S) -> Void where S : State

    Parameters

    oldState

    the state before the update

    newState

    the state after the update

  • Typealias for the Store listener unsubscribe closure

    Declaration

    Swift

    public typealias StoreUnsubscribe = () -> Void
  • Typealias for a type that returns the Store‘s state

    Declaration

    Swift

    public typealias GetState = () -> State
  • Typealias for the Store.anyDispatch function with the ability of managing the output with a promise

    Declaration

    Swift

    public typealias AnyDispatch = (Dispatchable) -> Promise<Any>