Anyone coming from Android where you're used to Vi...
# compose-ios
c
Anyone coming from Android where you're used to ViewModels and androidx-navigation? I'm new to ios on a greenfield project and id love to just re-use my old skills (instead of having to learn something new for essentially a POC) . Is mokomvvm the closest thing I can get? Any other suggestions?
👍 1
👍🏻 1
a
There are many options to choose, check this: https://kotlinlang.slack.com/archives/C3PQML5NU/p1691088725012219
You can also search in the history of #multiplatform channel, maybe some of the questions you might have are already answered there
K 1
c
thanks. i was hoping to get a pruned down recommendation of tools that are extremely similar to the "default" android way of doing things. so ill take that rec if anyone still has it. If not. it looks like @Sebastian Aigner used moko in his last video so i might go with that.
d
You can use StateFlow to share application state in multiplatform code
and use function collectAsState() to convert StateFlow to Compose State:
val state = stateFlow.collectAsState()
s
You can also take a look at https://github.com/Tlaster/PreCompose :)
c
thanks everyone
👍 1
s
j
I created my own NavHost with expect/actual so I could use androidx navigation in Android but share navigation container in iOS etc. Used then in iOS custom bridge between uiviewcontrolller with vanilla crossfade / animated content in same way in androidx but without Android specifics. You can always use Decompose, seems popular. For viewmodels I use my own Viewmodels which in Android using androidx viewmodel with actual and iOS inherit nothing. And re-use custom viewmodel scope interface. In end running my own MVVM stack but re-using Android where I can hidden from compose common world.
a
With Decompose you may not even need ViewModels. 😉
c
@Arkadii Ivanov decompose is towards the top of my list... BUT Im kinda used to the whole compose destination + ViewModel + hilt. so for my poc id like to have something comparable. i haven't taken too big a look at decompose, but is there basically a 1:1 replacement with compose destination + VM + hilt?
a
Not really. Decompose is closer to Fragments (decoupled from UI) + VM + proper manual DI (e.g. you can inject callbacks). Or you can have components full retained, and so you don't even need VMs.
1
You can also check Decompose-Router, which is also compile time safe, but also Compose-first.
m
https://github.com/Tlaster/PreCompose for almost same API as you are used to working on Android. you can almost copy/paste your Android code and it’ll work
c
awesome!