Hello, are PRs allowed for <this repository>? I wa...
# compose-desktop
d
Hello, are PRs allowed for this repository? I want to make the
ViewModel
and some of the navigation componenet multiplatform.
g
About your question, this repo is a fork of androidx, so you should contribute to androidx/androidx repo, see contribution guide: https://github.com/androidx/androidx#contribution-guide
Just curious why do you need multiplatform view model?
i
If you want to change ViewModel or Navigation better to make a PR to https://github.com/androidx/androidx. The JB fork contains only Compose implementation for Kotlin Native/Js, some bugfixes for Compose, and new experimental API. The majority of fixes/features eventually will be upstreamed to the original androidx repo.
d
I have my application written in full compose that supports both Android and Desktop and the navigation kinda sucks, and my Flows don't know when they need to be canceled, I don't have the
viewModelScope
for screen rotations
s
If you want a good alternative for navigation and viewmodel style class, Voyager is a good solution , it have both and it is multiplatform
a
in moko-mvvm ViewModel and LiveData already common - for all kotlin targets
g
I don’t have the
viewModelScope
for screen rotations
Should you just do this on level of DI for different platforms, in case of Android inject viewModelScope, in case of Desktop just pass your app-level scope Personally I fill that it step backward to introduce unnecessary Android abstraction for other platforms where it’s not even a problem. Abstraction on Android to hide viewModel implementation detail looks as better solution
d
But what if I need to recreate a composable that looks different based on the screen size? The scope should live when the screen is in the backstack and cancel it when it is removed from backstack
i
that looks different based on the screen size
You can use BoxWithConstraints to know the current window/screen size. Even on Android you can do this, and disable recreation of Activity in AndroidManifest.xml. Compose reactivity helps a lot to handle configuration changes.
g
But what if I need to recreate a composable that looks different based on the screen size
But it shouldn’t be responsibility of VM and as Igor mentioned above, it’s already possible to handle on level of composable, why have it on level of VM?
The scope should live when the screen is in the backstack and cancel it when it is removed from backstack
It looks as integration with navigation, yeah, it’s not available out of the box for Desktop, but my question was about VM, I agree, that would be great to have MPP navigation
👍🏻 1