Scala Reactive Extensions Observable apply Method

119 Views Asked by At

From the API docs of Rx Observable in scala:

http://reactivex.io/rxscala/scaladoc/#rx.lang.scala.Observable

There are two apply methods, one that takes a Subscriber and the other that takes an Observer. What is the difference between these two apply methods other than the fact that they take in different types to subscribe to an Observable?

1

There are 1 best solutions below

0
On BEST ANSWER

From Subscriber's documentation:

abstract class Subscriber[-T] extends Observer[T] with Subscription

An extension of the Observer trait which adds subscription handling (unsubscribe, isUnsubscribed, and add methods) and backpressure handling (onStart and request methods).

So we can assume that Observer's apply is more general binding which could take some proxied or self-defined observers and implements the observer pattern, while Subscriber's apply is more efficient internal binding.

See this question for the details.