select

Maps Store.state to a new StateFlow using given selector function. selector function is not called before selected state is actually accessed using StateFlow.value or collected. Also, it's not called if state is not changed. State is compared using equals so selection might be recalculated even if unrelated part of the state changed. However, if selection stays the same (again compared using equals), it's not emitted (just like every StateFlow). To optimize state selection, use select with Selector param.


fun <State, Selected> Store<State>.select(selector: Selector<State, Selected>): StateFlow<Selected>

Maps Store.state to a new StateFlow using given selector. Selector function is called only if Selector.isStateEqual returns false (by default it refers to equals). Also, selector function is not called before selected state is actually accessed using StateFlow.value or collected. Selector result is emitted only if Selector.isSelectionEqual returns false (by default it refers to equals).