jw
12/30/2016, 7:37 PMval increment = "Increment"
val decrement = "Decrement"
val actions = Observable.from(increment, increment, decrement, decrement);
val states = actions.scan(0, (action, state) -> when(action) {
is increment -> state + 1
is decrement -> state - 1
else -> throw IllegalArgumentException("Unknown action $action")
})
states.subscribe(state -> println(state))
0
1
2
1
0