https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
p

Patrick Jackson

06/17/2019, 3:06 PM
Hi All, a port of Redux to Kotlin multiplatform here: https://www.reduxkotlin.org . Currently a straight port of JS Redux, Thunk, and a Reselect implementation. Supports all platforms supported by Kotlin. Goal of project is to provide a standard on which an ecosystem of middleware/store enhancers/dev tools can grow. There's been several libs, now seems like a good time to set a common core to build upon. Feedback and contributions are welcome, and feel free to DM me. No samples for the time being, hope to have some up in the coming weeks.
I've been experimenting with Redux for MP Android & iOS and looks promising. With the new reactive style UI libs (Jetpack compose & Swift UI), there may be some interesting patterns with Redux. Have yet to play with these, but the JS world created Redux to handle state in complex react apps, so perhaps the same need will be present with Compose & SwiftUI.
a

Arkadii Ivanov

06/17/2019, 3:25 PM
Why everything is Any? E.g. Store state. Don't you want to make it generic?
p

Patrick Jackson

06/17/2019, 3:32 PM
up for discussion and changing, but I found in the JS world some store enhancers can return objects different from the appstate. Not to say we have to copy JS, but don't want to close doors to future features. Suppose it could be generic and use any as the type. Found there are ways with Kotlin to handle the Any type by wrapping in a function. For example there is a `castingReducer' function that allows casting to an Appstate with very little code.
Copy code
val reducer = castingReducer { state: Appstate, action ->
    when (action) {
        is UserLoggedInAction -> state.copy(user = action.user)
        ...
    }
  }