joesan
joesan

Reputation: 15385

Scala Reactive Extensions Observable apply Method

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?

Upvotes: 0

Views: 115

Answers (1)

Odomontois
Odomontois

Reputation: 16308

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.

Upvotes: 1

Related Questions