Stores

Store subscribers are types that are interested in receiving state updates from a store. Whenever the store updates its state it will notify all subscribers by calling the newState method on them. Subscribers need to conform to the StoreSubscriber protocol:

protocol StoreSubscriber {
    func newState(state: StoreSubscriberStateType)
}

Most of your StoreSubscribers will be in the view layer and update their representation whenever they receive a new state.

  • This class is the default implementation of the StoreType protocol. You will use this store in most of your applications. You shouldn’t need to implement your own store. You initialize the store with a reducer and an initial application state. If your app has multiple reducers you can combine them by initializing a MainReducer with all of your reducers as an argument.

    Declaration

    Swift

    open class Store<State> : StoreType
  • Defines the interface of Stores in ReSwift. Store is the default implementation of this interface. Applications have a single store that stores the entire application state. Stores receive actions and use reducers combined with these actions, to calculate state changes. Upon every state update a store informs all of its subscribers.

    Declaration

    Swift

    public protocol StoreType : DispatchingStoreType
  • Undocumented

    Declaration

    Swift

    public protocol StoreSubscriber : AnyStoreSubscriber
  • Undocumented

    Declaration

    Swift

    public protocol AnyStoreSubscriber : AnyObject