Hello guys , hope you are doing okey . So i'm work...
# multiplatform
a
Hello guys , hope you are doing okey . So i'm working on a multiplatform app with kotlin mpp , and coming from an android background i used to use the mvi pattern so just want to know if there is a way to implement it in kotlin mpp
j
You'd just need to separate the common code from the platform specific code. The UI updates would be in Android/iOS
a
it would be very helpful if you have some examples
j
Not MVI specific or my project but here is a MVP example: https://github.com/wiyarmir/kotlin-multiplatform-template . Should be able to adapt it
There is nothing really unique about KN and MV* but need to build abstractions around the platform specific implementations and decide what should be common vs platform
a
yeah , i think the big problem in mvi is wrapping the rxjava streams and operators
j
MVI is a pattern. You'd need to be flexible and adapt. RxJava isn't supported in common. There is Reaktive, could implement callbacks or wrap platform APIs
a
In Reaktive repo I'm implementing sample MPP module. It loads random kitten from network)) it uses MVI approach with view being injected from client side. So there is a store, state, intents, view interface etc. And client don't even interact with rx, it's internal. Checkout my PR with sample MPP module: https://github.com/badoo/Reaktive/pull/160 in next PRs I will update sample apps to use this module. Linux will use GTK3.
👍 1
a
@Arkadii Ivanov thank you , i'll check your pr , but i just have a question why can't we expect/actual on the rx extensions in each platform ?
a
Well you can. Then you will need to wrap your dummy common Observable to an appropriate platform's Observable and wrap back to common's one. For each operator. Also not sure how it will work with schedulers.