StateProvider

interface StateProvider

StateProvider is an abstraction used to supply the latest (and most accurate) value of a given State in a given scope, when read tracking is enabled.

This makes it possible for the same State object to return different State.value in various scopes, unlocking new possibilities. For example, a state that's read in post-mount will have the correct value without having to recreate that state object when its value gets updated. This works even if the previous phases were completely skipped.

Properties

Link copied to clipboard

Whether read tracking is enabled for this state provider.

Link copied to clipboard
abstract val treeId: Int

An identifier for the state provider's tree.

Functions

Link copied to clipboard
abstract fun getAndSet(source: TreeState?): TreeState?

Overrides the current scope with the given source and returns that (current) scope.

Link copied to clipboard
abstract fun <T> getValue(state: State<T>): T

Retrieves the current value of the given state from the active scope.

Link copied to clipboard
inline fun StateProvider.withScope(source: TreeState, block: () -> Unit)