TimeCapsuleOwner
Contract implemented by a screen's state holder (typically a ViewModel) so its state history can be recorded and restored by the TimeCapsule module.
Usage
class CounterViewModel : ViewModel(), TimeCapsuleOwner<CounterState> {
private val _state = MutableStateFlow(CounterState())
override val state: StateFlow<CounterState> = _state.asStateFlow()
override fun restoreState(state: CounterState) {
_state.value = state
}
}Content copied to clipboard
Restoring state is the integrator's responsibility to use safely: DevView does not guarantee the host app keeps working correctly after a state is pushed back into a running screen out of band.
See also
Properties
Functions
Link copied to clipboard
Pushes state back into the screen, restoring it as the current state.