O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Integrating with Emitter API

The Emitter interface is a much more powerful construct because it allows you to control the way items will be emitted into the Observable in a very granular fashion. Basically, the Observable will be controlled by these three methods:

  • onNext(): This is to supply a new value to the Observable
  • onError(): This is to notify about an error or exception that has occurred internally
  • onComplete(): This is to notify an Observable that there won't be any new values, and it can safely terminate

The Emitter interface is supplied to an Observable during its creation with the .create() method where the full type interface looks like this:

Observable.create(new ObservableOnSubscribe<Integer>() {    @Override    public void subscribe(ObservableEmitter<Integer> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required