RxJava - Just vs From

The difference should be clearer when you look at the behaviour of each when you pass it an Iterable (for example a List):

Observable.just(someList) will give you 1 emission - a List.

Observable.from(someList) will give you N emissions - each item in the list.

The ability to pass multiple values to just is a convenience feature; the following are functionally the same:

Observable.just(1, 2, 3);
Observable.from(1, 2, 3);

Difference between just() and from():

All though just() and from() appears to be doing the same work, it differs in number of emissions.

just() – Makes only 1 emission. Observable.just(new Integer[]{1, 2, 3}) makes one emission with Observer callback as onNext(Integer[] integers)

fromArray() – Makes N emissions. Observable.fromArray(new Integer[]{1, 2, 3}) makes three emission with Observer callback as onNext(Integer integer)

Tags:

Java

Rx Java