Android Studio as default has access to ViewModel class import androidx.lifecycle.ViewModel
.
How can I use this ViewModel into IntelliJ IDEA Kotlin desktop project (compose for desktop).
developer.android.com provide guide how to add the dependices just for Android Studio project.
Asked
Active
Viewed 636 times
1

denvercoder9
- 2,979
- 3
- 28
- 41

Exicode
- 23
- 6
2 Answers
1
That class is android specific so can't be used for Compose for Desktop.

John O'Reilly
- 10,000
- 4
- 41
- 63
-
May be there some specific analog for CfD? I can't find the way to make global access to mutableState variables. Now all code contains in main function, but if I want to separate it to a diffirent functions I need make class or object with mutableState variables to provide access to them from all that functions. The problem is mutableState variables available only in @Compose function context or lambda's. – Exicode Mar 14 '21 at 11:41
0
I did this with an object, used state flows, then called collectAsState() on those flows.

Matt Grier
- 206
- 2
- 9