I've been eyeing KMM a little now - I have a norma...
# multiplatform
e
I've been eyeing KMM a little now - I have a normal app (API from backend, displays a list of things) which also requires quite a bit of WebView work. It's currently built with Flutter but Flutter is pretty bad with WebView (context menu doesn't work, highlighting doesn't work, resizing WebView has huge performance penalty etc). Since KMM is fully native I expect all these to be non-problems, however I came to really like Flutter's Riverpod state management. I'm not a mobile dev (primarily backend), so I have no clue what's the standard in Android/iOS, but is there something similar to Riverpod in KMM, and is it possible to share state level logic with KMM as well?
I'm an indie developer but I really like the promise of fully native UI - however I'd prefer to also share state in order to minimise repetitive work
And this is a weird question but how viable is it to code for KMM/iOS/Android on VS Code, or should I just use 3 different text editors?
m
As for the tools, you can refer to the official documentation: https://kotlinlang.org/docs/multiplatform-mobile-setup.html#install-the-necessary-tools What’s not mentioned there is IntelliJ and AppCode which can be used to some extent instead of Android Studio / Xcode. I’ve never heard of native development on VS Code.
When it comes to the architecture there’s nowadays a lot of different open source projects and articles available. You can find a curated list of sample projects here: https://kotlinlang.org/docs/multiplatform-mobile-samples.html
possible to share state level logic with KMM as well
Yep. I recommend checking out just the lander to high level view of what’s available: https://kotlinlang.org/lp/mobile/
l
There’s a lot of options for state management in KMM. I’d recommend looking at one of moko-mvvm (MVVM), #decompose (BLoC), or Stately.
I tend to use decompose most of the time, but I also really enjoyed using moko-mvvm.
e
moko-mvvm looks kinda nice (set-up looks complicated though), thanks for the pointer!
I'm gonna check out the others too - was not a fan of BLoC in Flutter but maybe this would look nicer in Kotlin
m
Out of curiosity, where do you draw the line on handling state “manually” vs using a third party tooling 🤔 I’ve been working with fairly straightforward applications and managing view state with MVVM + UCs has been straightforward. Moreover, on Android side AndroidX VMs etc help a lot.
e
Like mentioned I'm a backend dev by trade, my only experience with mobile dev is Flutter so I didn't even know terms like MVVM
l
I’ve found that over time, the main differences are that I tend to converge to using a single Flow<DataClass> per component when using BLoC, and splitting into smaller components as needed, but tend to have one VM per screen with many Flows for individual pieces of data when using MVVM. Technically, there’s nothing stopping you from reversing those, though.