June 2017
Intermediate to advanced
400 pages
8h 44m
English
To emit a consecutive range of integers, you can use Observable.range(). This will emit each number from a start value and increment each emission until the specified count is reached. These numbers are all passed through the onNext() event, followed by the onComplete() event:
import io.reactivex.Observable; public class Launcher { public static void main(String[] args) { Observable.range(1,10) .subscribe(s -> System.out.println("RECEIVED: " + s)); } }
The output is as follows:
RECEIVED: 1 RECEIVED: 2 RECEIVED: 3 RECEIVED: 4 RECEIVED: 5 RECEIVED: 6 RECEIVED: 7 RECEIVED: 8 RECEIVED: 9 RECEIVED: 10
Note closely that the two arguments for Observable.range() are not lower/upper bounds. The first argument is the starting ...
Read now
Unlock full access