Replies: 2 comments
-
Any updates on this? @ge-org |
Beta Was this translation helpful? Give feedback.
0 replies
-
You could model your thunk builder to take Here's a modified sample val store = createStore(::reducer, applymiddleware(createThunkMiddleware()))
...
fun CoroutineScope.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() {
val myScope = CoroutineScope(Dispatchers.Default)
dispatch(myScope.fooThunk("my query"))
...
myScope.cancel()
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Great library, together with the Redux library it's a great fit for Kotlin multiplatform projects.
The example in the README launches a coroutine inside the thunk. Is there any good way to cancel the coroutine later? The way it is currently it's a fire & forget situation which is not ideal in many cases.
Beta Was this translation helpful? Give feedback.
All reactions