File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ A redux Thunk implementation for async action dispatch.
1919
2020 ...
2121
22- fun fetchFoo(dispatch: Dispatcher) {
22+ fun fetchFoo(dispatch: Dispatcher, getState: GetState, extraArg: Any? ) {
2323 dispatch(FetchingFooAction)
2424 launch {
2525 val result = api.foo()
@@ -31,10 +31,22 @@ A redux Thunk implementation for async action dispatch.
3131 }
3232 }
3333
34+ val fetchBar: Thunk = {dispatch, getState, extraArgument ->
35+ dispatch(FetchingBarAction)
36+ launch {
37+ val result = api.bar()
38+ if (result.isSuccessful()) {
39+ dispatch(FetchBarSuccess(result.payload)
40+ } else {
41+ dispatch(FetchBarFailure(result.message)
42+ }
43+ }
44+
3445 ...
3546
3647 fun bar() {
3748 dispatch(::fetchFoo)
49+ dispatch(fetchBar)
3850 }
3951```
4052
@@ -47,15 +59,15 @@ kotlin {
4759 sourceSets {
4860 commonMain { // <--- name may vary on your project
4961 dependencies {
50- implementation "org.reduxkotlin:redux-kotlin-thunk:0.2"
62+ implementation "org.reduxkotlin:redux-kotlin-thunk:0.2.3 "
5163 }
5264 }
5365 }
5466```
5567
5668For JVM only:
5769```
58- implementation "org.reduxkotlin:redux-kotlin-jvm-thunk:0.2"
70+ implementation "org.reduxkotlin:redux-kotlin-jvm-thunk:0.2.3 "
5971```
6072
6173[ badge-android ] : http://img.shields.io/badge/platform-android-brightgreen.svg?style=flat
You can’t perform that action at this time.
0 commit comments