Skip to content

Commit 049c18b

Browse files
authored
Update README.md
1 parent 8f77931 commit 049c18b

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

README.md

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,66 @@
1-
# Redux-Kotlin
2-
3-
![Test](https://github.com/reduxkotlin/redux-kotlin-thunk/workflows/Test/badge.svg)
1+
# Redux-Kotlin-Thunk
42

3+
[![Release](https://github.com/reduxkotlin/redux-kotlin-thunk/actions/workflows/release.yml/badge.svg)](https://github.com/reduxkotlin/redux-kotlin-thunk/actions/workflows/release.yml)
54
![badge][badge-android]
65
![badge][badge-native]
76
![badge][badge-js]
87
![badge][badge-jvm]
98
![badge][badge-linux]
109
![badge][badge-windows]
1110
![badge][badge-mac]
12-
![badge][badge-wasm]
11+
[![Slack chat](https://img.shields.io/badge/kotlinlang-%23redux-green?logo=slack&style=flat-square)][slack]
12+
[![Dokka docs](https://img.shields.io/badge/docs-dokka-orange?style=flat-square&logo=kotlin)](http://reduxkotlin.github.io/redux-kotlin-thunk)
13+
[![Version maven-central](https://img.shields.io/maven-central/v/org.reduxkotlin/redux-kotlin-thunk?logo=apache-maven&style=flat-square)](https://mvnrepository.com/artifact/org.reduxkotlin/redux-kotlin-thunk/latest)
14+
[![Version maven-snapshot](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Foss.sonatype.org%2Fcontent%2Frepositories%2Fsnapshots%2Forg%2Freduxkotlin%2Fredux-kotlin-thunk%2Fmaven-metadata.xml&logo=apache-maven&label=maven-snapshot&style=flat-square)](https://oss.sonatype.org/content/repositories/snapshots/org/reduxkotlin/redux-kotlin-thunk/)
1315

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

1820
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.
1921

20-
```
21-
val store = createStore(::reducer, applymiddleware(createThunkMiddleware()))
22-
23-
...
24-
25-
fun fooThunk(query: String): Thunk<AppState> = { dispatch, getState, extraArg ->
26-
dispatch(FetchingFooAction)
27-
launch {
28-
val result = api.foo(query)
29-
if (result.isSuccessful()) {
30-
dispatch(FetchFooSuccess(result.payload)
31-
} else {
32-
dispatch(FetchFooFailure(result.message)
33-
}
34-
}
35-
}
36-
37-
...
38-
39-
fun bar() {
40-
dispatch(fooThunk("my query"))
41-
}
22+
```kotlin
23+
val store = createStore(::reducer, applymiddleware(createThunkMiddleware()))
24+
25+
...
26+
27+
fun fooThunk(query: String): Thunk<AppState> = { dispatch, getState, extraArg ->
28+
dispatch(FetchingFooAction)
29+
launch {
30+
val result = api.foo(query)
31+
if (result.isSuccessful()) {
32+
dispatch(FetchFooSuccess(result.payload)
33+
} else {
34+
dispatch(FetchFooFailure(result.message)
35+
}
36+
}
37+
}
38+
39+
...
40+
41+
fun bar() {
42+
dispatch(fooThunk("my query"))
43+
}
4244
```
4345

4446
__How to add to project:__
4547

4648
Artifacts are hosted on maven central. For multiplatform, add the following to your shared module:
4749

48-
```
50+
```kotlin
4951
kotlin {
5052
sourceSets {
5153
commonMain { // <--- name may vary on your project
5254
dependencies {
53-
implementation "org.reduxkotlin:redux-kotlin-thunk:0.5.3"
55+
implementation("org.reduxkotlin:redux-kotlin-thunk:_")
5456
}
5557
}
5658
}
5759
```
5860

5961
For JVM only:
60-
```
61-
implementation "org.reduxkotlin:redux-kotlin-jvm-thunk:0.5.3"
62+
```kotlin
63+
implementation("org.reduxkotlin:redux-kotlin-thunk-jvm:_")
6264
```
6365

6466
[badge-android]: http://img.shields.io/badge/platform-android-brightgreen.svg?style=flat
@@ -74,4 +76,3 @@ For JVM only:
7476
[badge-windows]: http://img.shields.io/badge/platform-windows-informational.svg?style=flat
7577
[badge-mac]: http://img.shields.io/badge/platform-macos-lightgrey.svg?style=flat
7678
[badge-mac]: http://img.shields.io/badge/platform-macos-lightgrey.svg?style=flat
77-
[badge-wasm]: https://img.shields.io/badge/platform-wasm-darkblue.svg?style=flat

0 commit comments

Comments
 (0)