init(_:observe:)

Initializes a view store from a store which observes changes to state.

ViewStore.swift:602
@MainActor convenience init<State>(_ store: Store<State, ViewAction>, observe toViewState: @escaping (_ state: State) -> ViewState)

Parameters

store

A store.

toViewState

A transformation of ViewState to the state that will be observed for changes.

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.