Redux FAQ: Multiplatform
Table of Contents
- When should I learn Redux?
- When should I use Redux?
- Can Redux only be used with React?
- Do I need to have a particular build tool to use Redux?
What is "Multiplatform" Kotlin?
- Official Kotlin site
- Examples of multiplatform projects using ReduxKotlin
- Raywenderlich.com - Getting Started
Can I use existing JS Redux code?
Can I use React with ReduxKotlin?
Yes - but this has not been proven with a sample yet. This is on the roadmap. In theory this should work because the API for ReduxKotlin matches JS Redux. A minimal sample will be posted when available. If interested in creating a sample or collaborating, see the "Community" Section at the bottom of this page.
Does compiling to Native for iOS include a VM? Is there a lot of overhead?
Kotlin does not ship a VM to native. It compiles to a native executable with objC headers. KN does include an automated memory management scheme that does automatic reference counting and garbage collection. There does not appear to be a significant performance or memory overhead, however I have not seen benchmarks. For more details, checkout the Kotlin Native docs.
How do I structure a multiplatform kotlin project?
There some examples that demonstrate Android and iOS sharing code. JS examples will be added soon. Typically there is a shared module (or multiple shared modules) and the platforms pull it in as a dependency. Redux looks like a very promising pattern for multiplatform because the view layer can be very thin. Additionally Redux works well with Jetpack Compose and SwiftUI.
How is this related to the kotlin-redux wrapper?
ReduxKotlin.org and kotlin-redux wrapper are completed separate projects with different objectives. ReduxKotlin is a port of Redux to pure Kotlin. Kotlin-redux is a kotlin wrapper around the JS Redux library, which allows compiling to JS only.
Are coroutines usable on Native/iOS?
Yes. All the samples in this project use coroutines with a UI dispatcher and they perform reasonable well. However there is a limitation currently with coroutines on Native which only allows a single thread. The Jetbrains team is actively working on a solution. For now injecting your shared code with a coroutine context from the platform will allow you use a single threaded model now, and then switch to a multithreaded model easily in the future.