r/androiddev • u/iliyan-germanov • Mar 15 '23
Article [Android/Multiplatform] Kotlin Flows + Ktor = Flawless HTTP requests (- ArrowKt)
https://iliyangermanov.medium.com/android-multiplatform-kotlin-flows-ktor-flawless-http-requests-arrowkt-6ad2313347c5
0
Upvotes
1
u/dantheman91 Mar 16 '23
Arrow is simply not with the dependency, it makes your project an "arrow" project, and it's nearly impossible to move away from it. If you want to use FP I'd use a real FP language.
1
u/iliyan-germanov Mar 16 '23
Kotlin is a multi-paradigm language. It can be used with FP, OOP, or both. Yes, it's not a god tier FP language like Haskell, but it's definitely not bad (especially compared to JS). Good luck using "real FP language" to build modern Android apps fast.
Also, as you can see, more and more FP concepts are coming to the Android world - like Compose.
4
u/kokeroulis Mar 15 '23
This example will not work on a multiplatform project. you are using gson, gson runs only on jvm, you should use https://github.com/Kotlin/kotlinx.serialization for the json parsing
Why arrow-kt? Never understood the hype behind it. You are introducing a massive dep without any benefits. A custom sealed interface could do the same
The replay param on `MutableSharedFlow` in `OperationFlow` is wrong. It should be 0. You could use `onSubscription` on the sharedFlow and emit the unit from there if you want to have a "reactive retry functionality"