Skip to content

Coroutines

Miguel Panelo edited this page Feb 10, 2019 · 1 revision

Coroutines can be used to handle asynchronous reducers with the coroutines builder.

It can be used by having shared scope

Kaskade.create<TestAction, TestState>(TestState.State1) {
    coroutines(localScope) {
        on<TestAction.Action1> {
            TestState.State1
        }
        on<TestAction.Action2> {
            TestState.State2
        }
    }
}

or independent scopes

Kaskade.create<TestAction, TestState>(TestState.State1) {
    coroutines {
        on<TestAction.Action1>(localScope) {
            TestState.State1
        }
        on<TestAction.Action2>(newScope) {
            TestState.State2
        }
    }
}

Managing the scope is the responsibility of the client. Kaskade does not have the ability to cancel scopes by itself.

Clone this wiki locally