Closed jershell closed 7 months ago
Hi @jershell
please update to the just released 1.6.0-beta02
and change the line
viewModelFactory { FooBarViewModel() }
to viewModelFactory { initializer { FooBarViewModel() } }
That should fix the issue.
Is this initializer {}
block, the API moving forward for all platforms?
It really doesn't look appealing having these 2 inner blocks with an almost equal semantic name, ViewModelFactory
and initializer
.
Hi @jershell please update to the just released
1.6.0-beta02
and change the lineviewModelFactory { FooBarViewModel() }
toviewModelFactory { initializer { FooBarViewModel() } }
That should fix the issue.
Hi. I up version. Viewmodel is working. Thanks you!
Is this
initializer {}
block, the API moving forward for all platforms?
It's the API from Android/Google, not new one. There is another overload with trailing lambda, so the usual syntax will be like:
viewModel { FooBarViewModel() }
As for "2 inner blocks": One factory might contain multiple initializers for different types. It's useful if you want to create a single factory for all your ViewModel
types instead of separate ones for each viewModel
call
Wow 😲 I never used it TBH. Thanks
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Unable to use the lifecycle-viewmodel-compose with web target
Describe the bug "No ViewModelStoreOwner was provided via LocalViewModelStoreOwner"
Affected platforms
Versions
To Reproduce Steps and/or the code snippet to reproduce the behavior:
Expected behavior Label with current time on screen
Source code