StateProvider
public protocol StateProvider
StateProvider
defines a protocol for entities able to offer state publishers (Combine Publisher, RxSwift Observable,
ReactiveSwift SignalProducer) of certain StateType
, so everybody can observe the global state changes through this
container. Usually a Store
will implement that, but it can also be a StoreProjection
with a state that is derived from
the global source-of-truth.
The only protocol requirement is to offer a property statePublisher
that will allow other entities to subscribe to
state changes and react to those.
-
This can be a global state, or a view state that is a not a source-of-truth but only a struct calculated and derived from a global source-of-truth, without storage to avoid state inconsistency.
Declaration
Swift
associatedtype StateType
-
The state publisher that can be observed by counterparts
Declaration
Swift
var statePublisher: UnfailablePublisherType<StateType> { get }
-
eraseToAnyStateProvider()
Extension methodUndocumented
Declaration
Swift
public func eraseToAnyStateProvider() -> AnyStateProvider<StateType>
-
map(_:
Extension method) Undocumented
Declaration
Swift
public func map<NewStateType>(_ transform: @escaping (StateType) -> NewStateType) -> AnyStateProvider<NewStateType>