InitialState

@ThreadSafe
class InitialState

The InitialStateContainer is a lookaside table used by a ComponentTree to create initial states for Components. The idea is that the onCreateInitialState result for each component will be cached and stored here so that we can guarantee it's not called multiple times on multiple threads. We keep the initial states cached as long as there is a layout happening for the ComponentTree. As soon as we detect that all in-flights layout have terminated we can clean up the initial states cache.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
Link copied to clipboard
fun <T> getOrCreateInitialKState(key: String, hookIndex: Int, initializer: HookInitializer<T>, componentName: String): ComponentState<KStateContainer>

If an initial state for this component has already been created just return it, otherwise execute the initializer and cache the result.

Link copied to clipboard

Called when the ComponentTree creates a new StateHandler for a new layout computation. We keep track of this new StateHandler so that we know that we need to wait for this layout computation to finish before we can clear the initial states map.

Link copied to clipboard

Called when the ComponentTree commits a new StateHandler or discards one for a discarded layout computation.