reduxkotlin-thunk

Redux thunmk implementation for Redux-Kotlin. Mulitiplatform supported.

License

License

Categories

Categories

Kotlin Languages
GroupId

GroupId

org.reduxkotlin
ArtifactId

ArtifactId

redux-kotlin-thunk
Last Version

Last Version

0.5.5
Release Date

Release Date

Type

Type

pom
Description

Description

reduxkotlin-thunk
Redux thunmk implementation for Redux-Kotlin. Mulitiplatform supported.
Project URL

Project URL

https://github.com/reduxkotlin/redux-kotlin-thunk/
Source Code Management

Source Code Management

https://github.com/reduxkotlin/redux-kotlin-thunk/

Download redux-kotlin-thunk

How to add to project

<!-- https://jarcasting.com/artifacts/org.reduxkotlin/redux-kotlin-thunk/ -->
<dependency>
    <groupId>org.reduxkotlin</groupId>
    <artifactId>redux-kotlin-thunk</artifactId>
    <version>0.5.5</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/org.reduxkotlin/redux-kotlin-thunk/
implementation 'org.reduxkotlin:redux-kotlin-thunk:0.5.5'
// https://jarcasting.com/artifacts/org.reduxkotlin/redux-kotlin-thunk/
implementation ("org.reduxkotlin:redux-kotlin-thunk:0.5.5")
'org.reduxkotlin:redux-kotlin-thunk:pom:0.5.5'
<dependency org="org.reduxkotlin" name="redux-kotlin-thunk" rev="0.5.5">
  <artifact name="redux-kotlin-thunk" type="pom" />
</dependency>
@Grapes(
@Grab(group='org.reduxkotlin', module='redux-kotlin-thunk', version='0.5.5')
)
libraryDependencies += "org.reduxkotlin" % "redux-kotlin-thunk" % "0.5.5"
[org.reduxkotlin/redux-kotlin-thunk "0.5.5"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Redux-Kotlin

Test

badge badge badge badge badge badge badge badge

A redux Thunk implementation for async action dispatch. A Thunk must conform to the Thunk typealias, which is a function with 3 paramaters: dispatch, getState, & extraArg. A common use is to make a function return a Thunk. This allows passing params to the function.

NOTE: Before v0.4.0 Thunk was an interface. Kotlin 1.3.70 fixed a bug which allows using a typealias instead, which is more concise and closer to the JS implementation.

    val store = createStore(::reducer, applymiddleware(createThunkMiddleware()))
    
    ...
    
    fun fooThunk(query: String): Thunk<AppState> = { dispatch, getState, extraArg ->
        dispatch(FetchingFooAction)
        launch {
            val result = api.foo(query)
            if (result.isSuccessful()) {
                dispatch(FetchFooSuccess(result.payload)
            } else {
                dispatch(FetchFooFailure(result.message)
            }
        }  
    }
 
    ...
    
    fun bar() {
       dispatch(fooThunk("my query")) 
    }

How to add to project:

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:redux-kotlin-thunk:0.5.3"
            }
        }
 }

For JVM only:

  implementation "org.reduxkotlin:redux-kotlin-jvm-thunk:0.5.3"
org.reduxkotlin

Redux-Kotlin

Redux for Kotlin multiplatform

Versions

Version
0.5.5
0.5.4
0.5.3
0.4.0
0.2.9
0.2.8
0.2.7
0.2.6
0.2.5
0.2.4
0.2.3
0.2