A Redux Reselect implementation for memoized dispatch on state selectors. Forked from Reduks implementation.
Documentation to come.
Example usage:
Subscribe to a single substate:
//selecting a substate subscribes to changes. Lambda block will be executed when there is
//a change in value of `isLoading`
val subscriber: StoreSubscriber = store.select({ it.isLoading }) {
loadingIndicator.visibility = if (store.state.isLoading) View.VISIBLE else View.GONE
}
//invoking subcription unsubscribes. Do this when appropriate for component lifecycle
subscriber()
Subscribe to multiple substates:
val multiSubscription = store.selectors {
select({ it.isLoading }) {
loadingIndicator.visibility = if (store.state.isLoading) View.VISIBLE else View.GONE
}
select({ it.name }) {
nameTextView.text = store.state.name
}
}
//unsubscribe when appropriate
multiSubscription()
How to add to project:
Requires Kotlin 1.4.0. Artifacts are hosted on maven central. For multiplatform, add the following to your shared module:
kotlin {
sourceSets {
commonMain { // <--- name may vary on your project
dependencies {
implementation "org.reduxkotlin:reselect:0.5.5"
}
}
}
For JVM only:
implementation "org.reduxkotlin:reselect-jvm:0.5.5"