In activity by viewModel() is not working properly, the invalidate() method doesn't callback when the viewLifecycleOwner is started, viewModel() is missing the postInvalidate() logic like activityViewModel(), please tell me how should I do it in activity.
Can I modify the viewModel() code like this:
inline fun <T, reified VM : MavericksViewModel<S>, reified S : MavericksState> T.viewModel(
viewModelClass: KClass<VM> = VM::class,
crossinline keyFactory: () -> String = { viewModelClass.java.name }
): Lazy<VM> where T : ComponentActivity, T : MavericksView = lifecycleAwareLazy(this) {
val lifecycleOwner = this
MavericksViewModelProvider.get(
viewModelClass = viewModelClass.java,
stateClass = S::class.java,
viewModelContext = ActivityViewModelContext(this, intent.extras?.get(Mavericks.KEY_ARG)),
key = keyFactory()
).apply { _internal(lifecycleOwner, action = { lifecycleOwner.postInvalidate() }) }
}
In activity by viewModel() is not working properly, the invalidate() method doesn't callback when the viewLifecycleOwner is started, viewModel() is missing the postInvalidate() logic like activityViewModel(), please tell me how should I do it in activity.
Can I modify the viewModel() code like this: