Store

  • The primary container of an application’s state.

    The store both contains and mutates the state through a provided reducer as it’s sent actions. Use the didChange publisher to be notified of changes.

    See more

    Declaration

    Swift

    public final class Store<State> where State : Decodable, State : Encodable
  • Performs an action on a given state and returns a whole new version.

    A store is given a single root Reducer. As it’s sent actions, it runs the reducer to update the application’s state. The reducer can have subreducers to separate code out into modular parts.

    For a reducer’s own state and actions, implement the reduce(state:action:). For subreducers, implement the reduceNext(state:action:) method.

    See more

    Declaration

    Swift

    public protocol Reducer
  • Creates a proxy of the store object for use by middleware.

    Middleware may use the store proxy to retreive the current state, send actions, continue to the next middleware, or subscribe to store changes. With the proxy, middleware don’t have to worry about retaining the store. Instead, the proxy provides a safe API to access a weak reference to it.

    See more

    Declaration

    Swift

    public struct StoreProxy<State> where State : Decodable, State : Encodable