init(_:observe:send:removeDuplicates:)
Initializes a view store from a store which observes changes to state.
- iOS
- deprecated
- macOS
- deprecated
- tvOS
- deprecated
- watchOS
- deprecated
@MainActor init<State, Action>(_ store: Store<State, Action>, observe toViewState: @escaping (_ state: State) -> ViewState, send fromViewAction: @escaping (_ viewAction: ViewAction) -> Action, removeDuplicates isDuplicate: @escaping (_ lhs: ViewState, _ rhs: ViewState) -> Bool)
Parameters
- store
A store.
- toViewState
A transformation of
ViewState
to the state that will be observed for changes.- fromViewAction
A transformation of
ViewAction
that describes what actions can be sent.- isDuplicate
A function to determine when two
State
values are equal. When values are equal, repeat view computations are removed.
It is recommended that the observe
argument transform the store’s state into the bare minimum of data needed for the feature to do its job in order to not hinder performance. This is especially true for root level features, and less important for leaf features.
To read more about this performance technique, read the Performance article.