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

RxJava can be used to handle asynchronous reducers with the rx builder.

It can be used by having shared observers

Kaskade.create<TestAction, TestState>(TestState.State1) {
    rx({ observer }) {
        on<TestAction.Action1> {
            map { TestState.State1 }
        }
        on<TestAction.Action2> {
            map { TestState.State2 }
        }
    }
}

or independent observers Kaskade.create<TestAction, TestState>(TestState.State1) { rx { on<TestAction.Action1>({ observer1 }) { map { TestState.State1 } } on<TestAction.Action2>({ observer2 }) { map { TestState.State2 } } } }

The builder lambda has an Observable<ActionState> receiver that the observable can build upon and the lambda should return an Observable<TestState>

Subscribing to states

RxJava can also be used to observe states using the extension function

kaskade.stateObservable()
Clone this wiki locally