reduxkotlin / redux-kotlin

Redux implementation for Kotlin (supports multiplatform JVM, native, JS, WASM)
https://reduxkotlin.org
MIT License
426 stars 32 forks source link

Introduce TypedStore<State,Action>! #125

Closed mpetuska closed 1 year ago

mpetuska commented 1 year ago

Closes #92 Closes #46

mpetuska commented 1 year ago

Some additional tests are still missing but public API is final.

patjackson52 commented 1 year ago

I'm not following why adding a type for action to Store. What is the need this is fulfilling? To require a common subclass for all actions? I'm in favor of not requiring a type for actions. Most stores would use Any as action type and requiring a common subclass is just adding complexity & confusion imo.

The ReducerForAction type was used along with some other code as a way reduce type checking in reducers and make them more concise. I think a full example of how it was used is lacking. Not sure this is even a real issue.

mpetuska commented 1 year ago

To be clear, this feature set is entirely opt in. The benefits are typesafe dispatchers and reducers. The downsides are that some enchancers might become unavailable (e.g. thunk). In any case, traditional stores and reducers remain exactly the same. I'll bring back removed typealiases with deprecation in the next patch to this.

I personally missed typesafe store in some of my projects as well.

mpetuska commented 1 year ago

@patjackson52 PR is ready for review. Here are a few things I'd like you to double-check while reviewing: