object Observable
Provides various ways to construct new Observables.
- Alphabetic
- By Inheritance
- Observable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
amb[T](sources: Observable[T]*): Observable[T]
Mirror the one Observable in an Iterable of several Observables that first emits an item.
Mirror the one Observable in an Iterable of several Observables that first emits an item.
- sources
an Iterable of Observable sources competing to react first
- returns
an Observable that emits the same sequence of items as whichever of the source Observables first emitted an item
-
def
apply[T](f: (Subscriber[T]) ⇒ Unit): Observable[T]
Returns an Observable that will execute the specified function when someone subscribes to it.
Returns an Observable that will execute the specified function when someone subscribes to it.

Write the function you pass so that it behaves as an Observable: It should invoke the Subscriber's
onNext,onError, andonCompletedmethods appropriately.You can
addcustom Subscriptions to Subscriber. These Subscriptions will be called- when someone calls
unsubscribe. - after
onCompletedoronError.
See Rx Design Guidelines (PDF) for detailed information.
See
RxScalaDemo.createExampleGoodandRxScalaDemo.createExampleGood2.- T
the type of the items that this Observable emits
- f
a function that accepts a
Subscriber[T], and invokes itsonNext,onError, andonCompletedmethods as appropriate- returns
an Observable that, when someone subscribes to it, will execute the specified function
- when someone calls
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
combineLatest[T, R](sources: Iterable[Observable[T]])(combineFunction: (Seq[T]) ⇒ R): Observable[R]
Combines an Iterable of source Observables by emitting an item that aggregates the latest values of each of the source Observables each time an item is received from any of the source Observables, where this aggregation is defined by a specified function.
Combines an Iterable of source Observables by emitting an item that aggregates the latest values of each of the source Observables each time an item is received from any of the source Observables, where this aggregation is defined by a specified function.
Backpressure:
Fully supports backpressure.
Scheduler:
This method does not operate by default on a particular Scheduler.
- T
the common base type of source values
- R
the result type
- sources
the Iterable of source Observables
- combineFunction
the aggregation function used to combine the items emitted by the source Observables
- returns
an Observable that emits items that are the result of combining the items emitted by the source Observables by means of the given aggregation function
-
def
combineLatestDelayError[T, R](sources: Iterable[Observable[T]])(combineFunction: (Seq[T]) ⇒ R): Observable[R]
Combines an Iterable of source Observables by emitting an item that aggregates the latest values of each of the source Observables each time an item is received from any of the source Observables, where this aggregation is defined by a specified function and delays any error from the sources until all source Observables terminate.
Combines an Iterable of source Observables by emitting an item that aggregates the latest values of each of the source Observables each time an item is received from any of the source Observables, where this aggregation is defined by a specified function and delays any error from the sources until all source Observables terminate.
Backpressure:
Fully supports backpressure.
Scheduler:
This method does not operate by default on a particular Scheduler.
- T
the common base type of source values
- R
the result type
- sources
the Iterable of source Observables
- combineFunction
the aggregation function used to combine the items emitted by the source [Observable]]s
- returns
an Observable that emits items that are the result of combining the items emitted by the source Observables by means of the given aggregation function
-
def
create[S, T](asyncOnSubscribe: AsyncOnSubscribe[S, T]): Observable[T]
EXPERIMENTAL Returns an Observable that respects the back-pressure semantics.
EXPERIMENTAL Returns an Observable that respects the back-pressure semantics. When the returned Observable is subscribed to it will initiate the given AsyncOnSubscribe's life cycle for generating events.
Backpressure:
Fully supports backpressure.
Scheduler:
This method does not operate by default on a particular Scheduler.
- S
the state type
- T
the type of the items that this Observable emits
- asyncOnSubscribe
an implementation of AsyncOnSubscribe. There are many creation methods on the object for convenience.
- returns
an Observable that, when a Subscriber subscribes to it, will use the specified AsyncOnSubscribe to generate events
- Annotations
- @Experimental()
- See also
-
def
create[S, T](syncOnSubscribe: SyncOnSubscribe[S, T]): Observable[T]
EXPERIMENTAL Returns an Observable that respects the back-pressure semantics.
EXPERIMENTAL Returns an Observable that respects the back-pressure semantics. When the returned Observable is subscribed to it will initiate the given SyncOnSubscribe's life cycle for generating events.
Note: the SyncOnSubscribe provides a generic way to fulfill data by iterating over a (potentially stateful) function (e.g. reading data off of a channel, a parser). If your data comes directly from an asynchronous/potentially concurrent source then consider using AsyncOnSubscribe.
Backpressure:
Fully supports backpressure.
Scheduler:
This method does not operate by default on a particular Scheduler.
- S
the state type
- T
the type of the items that this Observable emits
- syncOnSubscribe
an implementation of SyncOnSubscribe There are many creation methods on the object for convenience.
- returns
an Observable that, when a Subscriber subscribes to it, will use the specified SyncOnSubscribe to generate events
- Annotations
- @Experimental()
- See also
-
def
defer[T](observable: ⇒ Observable[T]): Observable[T]
Returns an Observable that calls an Observable factory to create its Observable for each new Observer that subscribes.
Returns an Observable that calls an Observable factory to create its Observable for each new Observer that subscribes. That is, for each subscriber, the actual Observable is determined by the factory function.

The defer operator allows you to defer or delay emitting items from an Observable until such time as an Observer subscribes to the Observable. This allows an rx.lang.scala.Observer to easily obtain updates or a refreshed version of the sequence.
- T
the type of the items emitted by the Observable
- observable
the Observable factory function to invoke for each rx.lang.scala.Observer that subscribes to the resulting Observable
- returns
an Observable whose rx.lang.scala.Observers trigger an invocation of the given Observable factory function
-
def
empty: Observable[Nothing]
Returns an Observable that emits no data to the rx.lang.scala.Observer and immediately invokes its onCompleted method with the specified scheduler.
Returns an Observable that emits no data to the rx.lang.scala.Observer and immediately invokes its onCompleted method with the specified scheduler.
- returns
an Observable that returns no data to the rx.lang.scala.Observer and immediately invokes the rx.lang.scala.Observerr's onCompleted method with the specified scheduler
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
error(exception: Throwable): Observable[Nothing]
Returns an Observable that invokes an Observer.onError method when the Observer subscribes to it.
Returns an Observable that invokes an Observer.onError method when the Observer subscribes to it.

Scheduler:
This method does not operate by default on a particular Scheduler.
- exception
the particular
Throwableto pass to Observer.onError- returns
an Observable that invokes the Observer.onError method when the Observer subscribes to it
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
from[T](t: Try[T]): Observable[T]
Converts a
Tryinto anObservable.Converts a
Tryinto anObservable.Implementation note: the value will be immediately emitted each time an rx.lang.scala.Observer subscribes. Since this occurs before the rx.lang.scala.Subscription is returned, it in not possible to unsubscribe from the sequence before it completes.
- T
the type of value in the Try, and the type of items to be emitted by the resulting Observable
- t
the source Try
- returns
an Observable that either emits the value or the error in the Try.
-
def
from[T](iterable: Iterable[T]): Observable[T]
Converts an
Iterableinto an Observable.Converts an
Iterableinto an Observable.
Note: the entire iterable sequence is immediately emitted each time an Observer subscribes. Since this occurs before the
Subscriptionis returned, it is not possible to unsubscribe from the sequence before it completes.- T
the type of items in the
Iterablesequence and the type of items to be emitted by the resulting Observable- iterable
the source
Iterablesequence- returns
an Observable that emits each item in the source
Iterablesequence
-
def
from[T](f: Future[T])(implicit execContext: ExecutionContext): Observable[T]
Returns an Observable emitting the value produced by the Future as its single item.
Returns an Observable emitting the value produced by the Future as its single item. If the future fails, the Observable will fail as well.
- f
Future whose value ends up in the resulting Observable
- returns
an Observable completed after producing the value of the future, or with an exception
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
def
interval(initialDelay: Duration, period: Duration, scheduler: Scheduler): Observable[Long]
Returns an Observable that emits a
0Lafter theinitialDelayand ever increasing numbers after eachperiodof time thereafter, on a specified Scheduler.Returns an Observable that emits a
0Lafter theinitialDelayand ever increasing numbers after eachperiodof time thereafter, on a specified Scheduler.
Backpressure Support:
This operator does not support backpressure as it uses time. If the downstream needs a slower rate it should slow the timer or use something like onBackpressureDrop.
Scheduler:
you specify which Scheduler this operator will use.
- initialDelay
the initial delay time to wait before emitting the first value of
0L- period
the period of time between emissions of the subsequent numbers
- scheduler
the Scheduler on which the waiting happens and items are emitted
- returns
an Observable that emits a
0Lafter theinitialDelayand ever increasing numbers after eachperiodof time thereafter, while running on the given Scheduler
-
def
interval(initialDelay: Duration, period: Duration): Observable[Long]
Returns an Observable that emits a
0Lafter theinitialDelayand ever increasing numbers after eachperiodof time thereafter.Returns an Observable that emits a
0Lafter theinitialDelayand ever increasing numbers after eachperiodof time thereafter.
Backpressure Support:
This operator does not support backpressure as it uses time. If the downstream needs a slower rate it should slow the timer or use something like onBackpressureDrop.
Scheduler:
intervaloperates by default on thecomputationScheduler.- initialDelay
the initial delay time to wait before emitting the first value of 0L
- period
the period of time between emissions of the subsequent numbers
- returns
an Observable that emits a
0Lafter theinitialDelayand ever increasing numbers after eachperiodof time thereafter
-
def
interval(period: Duration, scheduler: Scheduler): Observable[Long]
Emits
0,1,2,...with a delay ofdurationbetween consecutive numbers.Emits
0,1,2,...with a delay ofdurationbetween consecutive numbers.
- period
duration between two consecutive numbers
- scheduler
the scheduler to use
- returns
An Observable that emits a number each time interval.
-
def
interval(duration: Duration): Observable[Long]
Emits
0,1,2,...with a delay ofdurationbetween consecutive numbers.Emits
0,1,2,...with a delay ofdurationbetween consecutive numbers.
- duration
duration between two consecutive numbers
- returns
An Observable that emits a number each time interval.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
just[T](items: T*): Observable[T]
Converts a sequence of values into an Observable.
Converts a sequence of values into an Observable.

Implementation note: the entire array will be immediately emitted each time an rx.lang.scala.Observer subscribes. Since this occurs before the rx.lang.scala.Subscription is returned, it in not possible to unsubscribe from the sequence before it completes.
- T
the type of items in the Array, and the type of items to be emitted by the resulting Observable
- items
the source Array
- returns
an Observable that emits each item in the source Array
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
never: Observable[Nothing]
Returns an Observable that never sends any items or notifications to an rx.lang.scala.Observer.
Returns an Observable that never sends any items or notifications to an rx.lang.scala.Observer.

This Observable is useful primarily for testing purposes.
- returns
an Observable that never sends any items or notifications to an rx.lang.scala.Observer
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
timer(delay: Duration, scheduler: Scheduler): Observable[Long]
Returns an Observable that emits
0Lafter a specified delay, on a specified Scheduler, and then completes.Returns an Observable that emits
0Lafter a specified delay, on a specified Scheduler, and then completes.
- delay
the initial delay before emitting a single
0L- scheduler
the Scheduler to use for scheduling the item
- returns
Observable that emits
0Lafter a specified delay, on a specified Scheduler, and then completes
-
def
timer(delay: Duration): Observable[Long]
Returns an Observable that emits
0Lafter a specified delay, and then completes.Returns an Observable that emits
0Lafter a specified delay, and then completes.
- delay
the initial delay before emitting a single
0L- returns
Observable that emits
0Lafter a specified delay, and then completes
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
using[T, Resource](resourceFactory: ⇒ Resource)(observableFactory: (Resource) ⇒ Observable[T], dispose: (Resource) ⇒ Unit, disposeEagerly: Boolean = false): Observable[T]
Constructs an Observable that creates a dependent resource object.
Constructs an Observable that creates a dependent resource object.

Scheduler:
usingdoes not operate by default on a particularScheduler.- resourceFactory
the factory function to create a resource object that depends on the Observable. Note: this is a by-name parameter.
- observableFactory
the factory function to create an Observable
- dispose
the function that will dispose of the resource
- disposeEagerly
if
truethen disposal will happen either on unsubscription or just before emission of a terminal event (onCompleteoronError).- returns
the Observable whose lifetime controls the lifetime of the dependent resource object
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
- See also
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
zip[T](observables: Observable[Observable[T]]): Observable[Seq[T]]
Given an Observable emitting
Nsource observables, returns an observable that emits Seqs ofNelements each.Given an Observable emitting
Nsource observables, returns an observable that emits Seqs ofNelements each. The first emitted Seq will contain the first element of each source observable, the second Seq the second element of each source observable, and so on.Note that the returned Observable will only start emitting items once the given
Observable[Observable[T]]has completed, because otherwise it cannot knowN.- observables
An Observable emitting N source Observables
- returns
an Observable that emits the zipped Seqs
-
def
zip[A, B, C, D](obA: Observable[A], obB: Observable[B], obC: Observable[C], obD: Observable[D]): Observable[(A, B, C, D)]
Given 4 observables, returns an observable that emits Tuples of 4 elements each.
Given 4 observables, returns an observable that emits Tuples of 4 elements each. The first emitted Tuple will contain the first element of each source observable, the second Tuple the second element of each source observable, and so on.
- returns
an Observable that emits the zipped Observables
-
def
zip[A, B, C](obA: Observable[A], obB: Observable[B], obC: Observable[C]): Observable[(A, B, C)]
Given 3 observables, returns an observable that emits Tuples of 3 elements each.
Given 3 observables, returns an observable that emits Tuples of 3 elements each. The first emitted Tuple will contain the first element of each source observable, the second Tuple the second element of each source observable, and so on.
- returns
an Observable that emits the zipped Observables
Deprecated Value Members
-
def
combineLatest[T, R](sources: Seq[Observable[T]])(combineFunction: (Seq[T]) ⇒ R): Observable[R]
Combines a list of source Observables by emitting an item that aggregates the latest values of each of the source Observables each time an item is received from any of the source Observables, where this aggregation is defined by a specified function.
Combines a list of source Observables by emitting an item that aggregates the latest values of each of the source Observables each time an item is received from any of the source Observables, where this aggregation is defined by a specified function.
- T
the common base type of source values
- R
the result type
- sources
the list of source Observables
- combineFunction
the aggregation function used to combine the items emitted by the source Observables
- returns
an Observable that emits items that are the result of combining the items emitted by the source Observables by means of the given aggregation function
- Annotations
- @deprecated
- Deprecated
(Since version 0.26.2) Use Observable.combineLatest[T,R](sources:Iterable[rx\.lang\.scala\.Observable[T]])(combineFunction:Seq[T]=>R):* instead
-
def
create[T](f: (Observer[T]) ⇒ Subscription): Observable[T]
Creates an Observable that will execute the given function when an rx.lang.scala.Observer subscribes to it.
Creates an Observable that will execute the given function when an rx.lang.scala.Observer subscribes to it.

Write the function you pass to
createso that it behaves as an Observable: It should invoke the Observer's onNext, onError, and onCompleted methods appropriately.See Rx Design Guidelines (PDF) for detailed information.
- T
the type of the items that this Observable emits.
- f
a function that accepts an
Observer[T], invokes itsonNext,onError, andonCompletedmethods as appropriate, and returns a rx.lang.scala.Subscription to allow the Observer to canceling the subscription.- returns
an Observable that, when an rx.lang.scala.Observer subscribes to it, will execute the given function.
- Annotations
- @deprecated
- Deprecated
(Since version 0.26.2) Use Observable.apply instead