Replies: 1 comment
-
|
Have you read the setup guide to setup the project? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a viewmodel like this:
`
class FormulasViewModel(container: ViewModelContainer , savedStateHolder: SavedStateHolder): ViewModel() {
val _state = MutableStateFlow(savedStateHolder.consumeRestored("state") as FormulasState)
init {
savedStateHolder.registerProvider("state"){
FormulasState()
}
}
val state = _state.stateIn(
viewModelScope,
SharingStarted.WhileSubscribed(5000L),
FormulasState()
)
}
`
And it is created with:
val formulasViewModel = viewModel(keys = listOf(viewModelContainer), modelClass = FormulasViewModel::class){ FormulasViewModel(viewModelContainer, it) }However when ever I try to run the code it throws an exception immediately like so:
java.lang.IllegalStateException: No StateHolder provided at moe.tlaster.precompose.stateholder.StateHolderKt$LocalStateHolder$1.invoke(StateHolder.kt:47) at moe.tlaster.precompose.stateholder.StateHolderKt$LocalStateHolder$1.invoke(StateHolder.kt:46) at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74) at androidx.compose.runtime.LazyValueHolder.getCurrent(ValueHolders.kt:29) at androidx.compose.runtime.LazyValueHolder.getValue(ValueHolders.kt:31) at androidx.compose.runtime.CompositionLocalMapKt.read(CompositionLocalMap.kt:90) at androidx.compose.runtime.ComposerImpl.consume(Composer.kt:2135) at moe.tlaster.precompose.viewmodel.ViewModelAdapterKt.viewModel(ViewModelAdapter.kt:55) at AppKt.App(App.kt:16)Beta Was this translation helpful? Give feedback.
All reactions