package scala
This package contains all classes that RxScala users need.
It basically mirrors the structure of package rx, but some changes were made to make it more Scala-idiomatic.
- Alphabetic
- By Inheritance
- scala
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
trait
DecorateAsJava extends AnyRef
These functions convert RxScala types to RxJava types.
These functions convert RxScala types to RxJava types. Pure Scala projects won't need them, but they will be useful for polyglot projects.
-
trait
DecorateAsScala extends AnyRef
These functions convert RxJava types to RxScala types.
These functions convert RxJava types to RxScala types. Pure Scala projects won't need them, but they will be useful for polyglot projects.
-
implicit final
class
FutureToObservable[T] extends AnyVal
Adds a toObservable extension method to Future
-
sealed
trait
Notification[+T] extends AnyRef
Emitted by Observables returned by rx.lang.scala.Observable.materialize.
-
trait
Observable[+T] extends AnyRef
The Observable interface that implements the Reactive Pattern.
-
implicit final
class
ObservableExtensions[T] extends AnyVal
Adds a toObservable extension method to Iterable
-
trait
Observer[-T] extends AnyRef
Provides a mechanism for receiving push-based notifications.
Provides a mechanism for receiving push-based notifications.
After an Observer calls an rx.lang.scala.Observable's
subscribemethod, the Observable calls the Observer'sonNextmethod to provide notifications. A well-behaved Observable will call an Observer'sonCompletedoronErrormethods exactly once. -
implicit final
class
OptionToObservable[T] extends AnyVal
Adds a toObservable extension method to Option
- trait Producer extends AnyRef
-
trait
Scheduler extends AnyRef
Represents an object that schedules units of work.
-
trait
Subject[T] extends Observable[T] with Observer[T]
A Subject is an Observable and an Observer at the same time.
-
abstract
class
Subscriber[-T] extends Observer[T] with Subscription
An extension of the Observer trait which adds subscription handling (unsubscribe, isUnsubscribed, and
addmethods) and backpressure handling (onStart and request methods).An extension of the Observer trait which adds subscription handling (unsubscribe, isUnsubscribed, and
addmethods) and backpressure handling (onStart and request methods).After a Subscriber calls an Observable's
subscribemethod, the Observable calls the Subscriber's onNext method to emit items. A well-behaved Observable will call a Subscriber's onCompleted method exactly once or the Subscriber's onError method exactly once.Similarly to the RxJava
Subscriber, this class has two constructors:The first constructor takes as argument the child Subscriber from further down the pipeline and is usually only needed together with lift:
myObservable.lift((subscriber: Subscriber[T]) => new Subscriber[T](subscriber) { override def onStart(): Unit = ... override def onNext(n: T): Unit = ... override def onError(e: Throwable): Unit = ... override def onCompleted(): Unit = ... })
The second constructor takes no arguments and is typically used with the subscribe method:
myObservable.subscribe(new Subscriber[T] { override def onStart(): Unit = ... override def onNext(n: T): Unit = ... override def onError(e: Throwable): Unit = ... override def onCompleted(): Unit = ... })
Notice that these two constructors are not (as usually in Scala) in the companion object, because if they were, we couldn't create anonymous classes implementing
onStart/onNext/onError/onCompletedas in the examples above. However, there are more constructors in the companion object, which allow you to construct Subscribers from givenonNext/onError/onCompletedlambdas. -
trait
Subscription extends AnyRef
Subscriptions are returned from all
Observable.subscribemethods to allow unsubscribing.Subscriptions are returned from all
Observable.subscribemethods to allow unsubscribing.This interface is the equivalent of
IDisposablein the .NET Rx implementation. -
implicit final
class
TryToObservable[T] extends AnyVal
Adds a toObservable extension method to Try
- trait Worker extends Subscription
Value Members
-
object
ImplicitFunctionConversions
These function conversions convert between Scala functions and Rx
Funcs andActions.These function conversions convert between Scala functions and Rx
Funcs andActions. Most RxScala users won't need them, but they might be useful if one wants to use therx.Observabledirectly instead of usingrx.lang.scala.Observableor if one wants to use a Java library taking/returningFuncs andActions. This object only contains conversions between functions. For conversions between types, use rx.lang.scala.JavaConversions. -
object
JavaConversions
These functions convert between RxScala types and RxJava types.
These functions convert between RxScala types and RxJava types. Pure Scala projects won't need them, but they will be useful for polyglot projects. This object only contains conversions between types. For conversions between functions, use rx.lang.scala.ImplicitFunctionConversions.
-
object
JavaConverters extends DecorateAsJava with DecorateAsScala
Provides conversion functions
asJavaandasScalato convert between RxScala types and RxJava types.Provides conversion functions
asJavaandasScalato convert between RxScala types and RxJava types.Example:
import rx.lang.scala.JavaConverters._ val javaObs = Observable.just(1, 2, 3).asJava val scalaObs = javaObs.asScala
-
object
Notification
Provides pattern matching support and constructors for Notifications.
Provides pattern matching support and constructors for Notifications.
Example:
import Notification._ Observable.just(1, 2, 3).materialize.subscribe(n => n match { case OnNext(v) => println("Got value " + v) case OnCompleted => println("Completed") case OnError(err) => println("Error: " + err.getMessage) })
-
object
Observable
Provides various ways to construct new Observables.
- object Observer extends ObserverFactoryMethods[Observer]
- object Producer
-
object
Subject
Subject that, once an
Observerhas subscribed, emits all subsequently observed items to the subscriber.Subject that, once an
Observerhas subscribed, emits all subsequently observed items to the subscriber.
val subject = Subject[String]() // observer1 will receive all onNext and onCompleted events subject.subscribe(observer1) subject.onNext("one") subject.onNext("two") // observer2 will only receive "three" and onCompleted subject.subscribe(observer2) subject.onNext("three") subject.onCompleted()
Example: - object Subscriber extends ObserverFactoryMethods[Subscriber]
- object Subscription
- object Worker