hello. i want to start moving my viewModels in KMM...
# multiplatform
a
hello. i want to start moving my viewModels in KMM, but I'm not sure how to communicate back with the UI layer. I'm thinking of using the KMMViewModel library (please let me know if there's a better one) and they use state flow as an example, but i'm not using composable UI to justify using state flows (or is it ?!), the apps are entirely based on and using reactive programming (*rx-java and rx-swift and badoo.re*aktive in KMM). I could use rx to communicate back with the views, but they're not really lifecycle aware... so i'm a bit stuck on which technology to use, or library or ... something. I'd use rx, but somehow make it lifecycle aware .... Any suggestions on how i could approach this ?
a
You can try using Lifecycle from the Essenty library, which makes it multiplatform. The Lifecycle can be tied to the Activity/Fragment on Android, to the App/ViewController lifecycle on iOS, etc. You can also try using Decompose, which leverages Essenty and provides lifecycle-aware navigation. Depends on how you manage navigation in your project, and whether you want the navigation to be also multiplatform or platform-specific.
We could also think about adding
Observable#withLifecycle
extension - a Reaktive alternative to
Flow#flowWithLifecycle
, if you find it useful.