Type Aliases

The following type aliases are available globally.

  • An app should have a single real Store, holding a single source-of-truth. However, we can “derive” this store to small subsets, called store projections, that will handle either a smaller part of the state or action tree, or even a completely different type of actions and states as long as we can map back-and-forth to the original store types. It won’t store anything, only project the original store. For example, a View can define a completely custom View State and View Action, and we can create a StoreProjection that works on these types, as long as it’s backed by a real store which State and Action types can be mapped somehow to the View State and View Action types. The Store Projection will take care of translating these entities.

    Declaration

    Swift

    public typealias StoreProjection<ViewAction, ViewState> = AnyStoreType<ViewAction, ViewState>
  • State reducer: takes current state and an action, computes the new state.
    (ActionType, StateType) -> StateType

    Declaration

    Swift

    @available(*, deprecated, message: "Use `MutableReduceFunction` instead of `ReduceFunction`. The inout state improves performance. SwiftRex 1.0 will remove this typealias")
    public typealias ReduceFunction<ActionType, StateType> = (ActionType, StateType) -> StateType
  • Abstraction over subscriber/observer types from reactive frameworks. For this specific case, the failure/error is Never, meaning that this subscriber can only subscribe to publishers that don’t emit errors. This abstraction uses concept similar to type-erasure or protocol witness pattern, wrapping the behaviour of concrete implementations and delegating to them once the wrapper funcions are called.

    Declaration

    Swift

    public typealias UnfailableSubscriberType<Element> = SubscriberType<Element, Never>
  • Abstraction over publisher/observable/signal producer types from reactive frameworks. For this specific case, the failure/error is Never, meaning that this publisher can’t emit error. This abstraction uses concept similar to type-erasure or protocol witness pattern, wrapping the behaviour of concrete implementations and delegating to them once the wrapper funcions are called.

    Declaration

    Swift

    public typealias UnfailablePublisherType<Element> = PublisherType<Element, Never>
  • Abstraction over passthrough subject types (PassthroughSubject, PublishSubject, Signal) from reactive frameworks. For this specific case, the failure/error is Never, meaning that this subject can’t emit error. This abstraction uses concept similar to type-erasure or protocol witness pattern, wrapping the behaviour of concrete implementations and delegating to them once the wrapper funcions are called.

    Declaration

    Swift

    public typealias UnfailableSubject<Element> = SubjectType<Element, Never>
  • Abstraction over subject types able to keep the last object (CurrentValueSubject, BehaviorSubject, MutableProperty, Variable) from reactive frameworks. For this specific case, the failure/error is Never, meaning that this subject can’t emit error. This abstraction uses concept similar to type-erasure or protocol witness pattern, wrapping the behaviour of concrete implementations and delegating to them once the wrapper funcions are called.

    Declaration

    Swift

    public typealias UnfailableReplayLastSubjectType<Element> = ReplayLastSubjectType<Element, Never>
  • Zero-argument function that returns the current state.
    () -> StateType

    Declaration

    Swift

    public typealias GetState<StateType> = () -> StateType
  • State reducer: takes inout version of the current state and an action, computes the new state changing the provided mutable state.
    (ActionType, inout StateType) -> Void

    Declaration

    Swift

    public typealias MutableReduceFunction<ActionType, StateType> = (ActionType, inout StateType) -> Void