RxJava Tutorial on RxJava How Observable works

observables represents the sources of data where as observers (subscribers) listen to them. in nutshell, an observable emits items and a subscriber then consumes these items.

observable

  • observable provides data once subscriber starts listening.

  • observable can emit any number of items.

  • observable can emit only signal of completion as well with no item.

  • observable can terminate successfully.

  • observable may never terminate. e.g. a button can be clicked any number of times.

  • observable may throw error at any point of time.

subscriber

  • observable can have multiple subscribers.

  • when an observable emits an item, each subscriber onnext() method gets invoked.

  • when an observable finished emitting items, each subscriber oncomplete() method gets invoked.

  • if an observable emits error, each subscriber onerror() method gets invoked.