This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generate fibonacci sequence using Rxjava 2. | |
// This is an example to write a stream of events when future events depend on previous events, using reactive programming. | |
Flowable.generate(Callable { 0 to 1 }, BiFunction { prev:Pair<Int, Int>, emitter: Emitter<Int> -> | |
val next = prev.first + prev.second | |
emitter.onNext(prev.second) | |
prev.second to next | |
}) | |
.take(100) | |
.subscribe { |