jwstegemann / fritz2

Easily build reactive web-apps in Kotlin based on flows and coroutines.
https://www.fritz2.dev
MIT License
656 stars 28 forks source link

mobile multiplatform example #236

Closed maiermic closed 3 years ago

maiermic commented 3 years ago

IMO the main selling point of fritz2 and the Kotlin multiplatform project is the amount of code you can share with multiple platforms using native UI and good native interoperability. The full-stack examples (Ktor-Full-Stack and Spring TodoMVC) showcase how to share code between server and frontend (web UI). This article explains how to share code between iOS, Android and web UI using Kotlin React for the web UI and MVI (model view intent) pattern. Is fritz2 suitable to do something similar? I'd really like to see an example that shows how to share code between iOS, Android and fritz2 (native UI on each platform).

jillesvangurp commented 3 years ago

We are currently rebuilding our app using Fritz2 and we are using Cordova to package it up. This "just works"; it's simple and straightforward but it's obviously not native because it's framework intended for browser applications. You can use cordova plugins to expose native functionality. We are considering to write a few of our own plugins to work with some sdks that we have access to.

Fritz2 projects are already set up as multiplatform projects. So, yes, you can reuse cross multiplatform libraries. I have a few of those on Github and we are actually using them in this app as well as in an Android native app that we are replacing with this. We never had an IOS app but it should just work there as well. Basically, all you have to do is add the dependency.

Regarding MVI, that looks similar to what Fritz2 is doing as well as what frameworks like Jetpack Compose and SwiftUI do. Basically state is represented using Kotlin's StateFlow and views update by collecting those. The only way to trigger state changes is via event handlers on stores.

ghost commented 3 years ago

As there are no further questions open and the answer is fine and still valid (no concept change of fritz2 ;-) ), I close this issue.