The Observable.create method

Let's look at the signature of the method first:

public final static <T> Observable<T> create(OnSubscribe<T>)

It takes a parameter of type OnSubscribe. This interface extends the Action1<Subscriber<? super T>> interface; in other words, this type has only one method, taking one argument of type Subscriber<T> and returning nothing. This function will be called every time the Observable.subscribe() method is invoked. Its argument, an instance of the Subscriber class, is in fact the observer, subscribing to the Observable instance (here, the Subscriber class and Observer interface have the same role). We'll be talking about them later in this chapter). We can invoke the onNext(), onError(), and onCompleted() methods on ...

Get Learning Reactive Programming with Java 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.