https://kotlinlang.org logo
#orbit-mvi
Title
# orbit-mvi
b

Benoît

10/22/2021, 2:38 PM
Hey guys, I'm considering using orbit-mvi for our project, currently I'm using MobiusKt by Drew Carlson but the lack of union types in Kotlin makes it too verbose. We are building a Multiplatform project, is there anything specific that needs to be done, or something to be aware of, when writing code with orbit-mvi for iOS?
a

appmattus

10/22/2021, 3:37 PM
hi @Benoît, KMM is still in early process, you can find most of the details in this thread. https://kotlinlang.slack.com/archives/CPM6UMD2P/p1631800560020000 Basically, I'm still to finish writing up the main notes. Saying that @Guilherme Delgado has been playing around with it in more detail. Pain points, while the Android version of the library uses SavedStateHandle support, when using the library in KMM you lose this. Effectively it means you need to think much more about how caching works within your app. That being said apps typically shouldn't be storing much in SavedStateHandle anyway so I'd certainly suggest caching in a database where appropriate. Thread talking a little bit about that https://kotlinlang.slack.com/archives/CPM6UMD2P/p1634286811063700 Aside from the above, at the moment we generate SwiftUI/Combine based code for the iOS side, this may not suit everyone due to the min iOS 14.1 requirement. So if there's a different mapping that can help target other setups please shout. @Guilherme Delgado, do you have any tips you could share?
b

Benoît

10/22/2021, 4:03 PM
Thanks a lot for all of this. We are using SwiftUI on iOS and we've already came up with ways to consumer Flows and sealed classes to generate UI with SwiftUIs so we should be good. About the SavedStateHandle, this is mainly required for Android right? As far as I know iOS doesn't have configuration changes like Android does
a

appmattus

10/22/2021, 4:09 PM
well its also how to handle process death or rather restoration afterwards which iOS does also have
☝️ 1
g

Guilherme Delgado

10/22/2021, 4:21 PM
Hello @Benoît, as Matthew mention, for me, the only “pain point” in using Orbit-MVI in KMM is the state restoration. For me it’s the only thing keeping me from using this in “production”. Orbit-MVI for Android it’s a no brainer. Regarding my experimentations, I’ve a sample that I’ll sharing as soon as possible, where I user Orbit-MVI and a FSM in the shared code to provide “state logic” for the UI. There’s 🔨 to patch this restoration thing, but I’m not going to mention 😅 since it’s not the way to go.
b

Benoît

10/22/2021, 4:29 PM
From what you're saying sharing logic by writing a container is possible with the current version of Orbit-MVI, the only issue is when it comes to restoring state, right? I can live with that
👍 2
g

Guilherme Delgado

10/22/2021, 4:42 PM
yup
and the logic used for Android or KMM it’s the same
👍 1
(baring in mind you wont be passing a savedstatehandle instance to the container)
4 Views