trait Subject[T] extends Observable[T] with Observer[T]
A Subject is an Observable and an Observer at the same time.
- Alphabetic
- By Inheritance
- Subject
- Observer
- 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
-
def
++[U >: T](that: Observable[U]): Observable[U]
Returns an Observable that first emits the items emitted by
this, and then the items emitted bythat.Returns an Observable that first emits the items emitted by
this, and then the items emitted bythat.
- that
an Observable to be appended
- returns
an Observable that emits items that are the result of combining the items emitted by this and that, one after the other
- Definition Classes
- Observable
-
def
+:[U >: T](elem: U): Observable[U]
Returns an Observable that emits a specified item before it begins to emit items emitted by the source Observable.
Returns an Observable that emits a specified item before it begins to emit items emitted by the source Observable.
- elem
the item to emit
- returns
an Observable that emits the specified item before it begins to emit items emitted by the source Observable
- Definition Classes
- Observable
-
def
:+[U >: T](elem: U): Observable[U]
Returns an Observable that first emits the items emitted by
this, and thenelem.Returns an Observable that first emits the items emitted by
this, and thenelem.- elem
the item to be appended
- returns
an Observable that first emits the items emitted by
this, and thenelem.
- Definition Classes
- Observable
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
amb[U >: T](that: Observable[U]): Observable[U]
Given two Observables, mirror the one that first emits an item.
Given two Observables, mirror the one that first emits an item.
- that
an Observable competing to react first
- returns
an Observable that emits the same sequence of items as whichever of
thisorthatfirst emitted an item.
- Definition Classes
- Observable
-
def
apply(subscriber: Subscriber[T]): Subscription
Call this method to subscribe an Subscriber for receiving items and notifications from the Observable.
Call this method to subscribe an Subscriber for receiving items and notifications from the Observable.
A typical implementation of
subscribedoes the following:It stores a reference to the Observer in a collection object, such as a
List[T]object.It returns a reference to the rx.lang.scala.Subscription interface. This enables Subscribers to unsubscribe, that is, to stop receiving items and notifications before the Observable stops sending them, which also invokes the Subscriber's onCompleted method.
An Observable instance is responsible for accepting all subscriptions and notifying all Subscribers. Unless the documentation for a particular Observable implementation indicates otherwise, Subscribers should make no assumptions about the order in which multiple Subscribers will receive their notifications.
Scheduler:
This method does not operate by default on a particular Scheduler.
- subscriber
the Subscriber
- returns
a rx.lang.scala.Subscription reference whose
unsubscribemethod can be called to stop receiving items before the Observable has finished sending them
- Definition Classes
- Observable
- See also
-
def
apply(observer: Observer[T]): Subscription
Call this method to subscribe an rx.lang.scala.Observer for receiving items and notifications from the Observable.
Call this method to subscribe an rx.lang.scala.Observer for receiving items and notifications from the Observable.
A typical implementation of
subscribedoes the following:It stores a reference to the Observer in a collection object, such as a
List[T]object.It returns a reference to the rx.lang.scala.Subscription interface. This enables Observers to unsubscribe, that is, to stop receiving items and notifications before the Observable stops sending them, which also invokes the Observer's onCompleted method.
An
Observable[T]instance is responsible for accepting all subscriptions and notifying all Observers. Unless the documentation for a particularObservable[T]implementation indicates otherwise, Observers should make no assumptions about the order in which multiple Observers will receive their notifications.Scheduler:
This method does not operate by default on a particular Scheduler.
- observer
the observer
- returns
a rx.lang.scala.Subscription reference whose
unsubscribemethod can be called to stop receiving items before the Observable has finished sending them
- Definition Classes
- Observable
- See also
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
val
asJavaObservable: rx.Observable[_ <: T]
- Definition Classes
- Subject → Observable
- val asJavaObserver: rx.Observer[_ >: T]
-
def
cache: Observable[T]
This method has similar behavior to
Observable.replayexcept that this auto-subscribes to the source Observable rather than returning a start function and an Observable.This method has similar behavior to
Observable.replayexcept that this auto-subscribes to the source Observable rather than returning a start function and an Observable.
This is useful when you want an Observable to cache responses and you can't control the subscribe/unsubscribe behavior of all the rx.lang.scala.Observers.
When you call
cache, it does not yet subscribe to the source Observable. This only happens whensubscribeis called the first time on the Observable returned bycache.Note: You sacrifice the ability to unsubscribe from the origin when you use the
cache()operator so be careful not to use this operator on Observables that emit an infinite or very large number of items that will use up memory.- returns
an Observable that when first subscribed to, caches all of its notifications for the benefit of subsequent subscribers.
- Definition Classes
- Observable
-
def
cacheWithInitialCapacity(capacity: Int): Observable[T]
Caches emissions from the source Observable and replays them in order to any subsequent Subscribers.
Caches emissions from the source Observable and replays them in order to any subsequent Subscribers. This method has similar behavior to replay except that this auto-subscribes to the source Observable rather than returning a ConnectableObservable for which you must call connect to activate the subscription.

This is useful when you want an Observable to cache responses and you can't control the subscribe/unsubscribe behavior of all the Subscribers.
When you call this method, it does not yet subscribe to the source Observable and so does not yet begin caching items. This only happens when the first Subscriber calls the resulting Observable's
subscribemethod.**Note:** You sacrifice the ability to unsubscribe from the origin when you use the this method. So be careful not to use this method on Observables that emit an infinite or very large number of items that will use up memory.
Backpressure Support:
This operator does not support upstream backpressure as it is purposefully requesting and caching everything emitted.
Scheduler:
This method does not operate by default on a particular Scheduler.
**Note:** The
capacityhint is not an upper bound on cache size. For that, consider replay(Int) in combination with ConnectableObservable.autoConnect or similar.- capacity
hint for number of items to cache (for optimizing underlying data structure)
- returns
an Observable that, when first subscribed to, caches all of its items and notifications for the benefit of subsequent Subscribers
- Definition Classes
- Observable
- See also
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
collect[R](pf: PartialFunction[T, R]): Observable[R]
Return a new Observable by applying a partial function to all elements of this Observable on which the function is defined.
Return a new Observable by applying a partial function to all elements of this Observable on which the function is defined.
- R
the element type of the returned Observable.
- pf
the partial function which filters and maps the Observable.
- returns
a new Observable by applying a partial function to all elements of this Observable on which the function is defined.
- Definition Classes
- Observable
-
def
combineLatest[U](that: Observable[U]): Observable[(T, U)]
Combines two observables, emitting a pair of the latest values of each of the source observables each time an event is received from one of the source observables.
Combines two observables, emitting a pair of the latest values of each of the source observables each time an event is received from one of the source observables.
- that
The second source observable.
- returns
An Observable that combines the source Observables
- Definition Classes
- Observable
-
def
combineLatestWith[U, R](that: Observable[U])(selector: (T, U) ⇒ R): Observable[R]
Combines two observables, emitting some type
Rspecified in the functionselector, each time an event is received from one of the source observables, where the aggregation is defined by the given function.Combines two observables, emitting some type
Rspecified in the functionselector, each time an event is received from one of the source observables, where the aggregation is defined by the given function.- that
The second source observable.
- selector
The function that is used combine the emissions of the two observables.
- returns
An Observable that combines the source Observables according to the function
selector.
- Definition Classes
- Observable
-
def
concat[U]: Observable[U]
[use case]
[use case]- Definition Classes
- Observable
Full Signaturedef concat[U](implicit evidence: <:<[Observable[T], Observable[Observable[U]]]): Observable[U]
-
def
concatEager[U](capacityHint: Int)(implicit evidence: <:<[Observable[T], Observable[Observable[U]]]): Observable[U]
EXPERIMENTAL Concatenates an Observable sequence of Observables eagerly into a single stream of values.
EXPERIMENTAL Concatenates an Observable sequence of Observables eagerly into a single stream of values.
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source Observables as they are observed. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Backpressure:
Backpressure is honored towards the downstream, however, due to the eagerness requirement, sources are subscribed to in unbounded mode and their values are queued up in an unbounded buffer.
Scheduler:
This method does not operate by default on a particular Scheduler.
- capacityHint
hints about the number of expected values in an Observable
- returns
an Observable that emits items all of the items emitted by the Observables emitted by
this, one after the other, without interleaving them
- Definition Classes
- Observable
- Annotations
- @Experimental()
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
-
def
concatEager[U](implicit evidence: <:<[Observable[T], Observable[Observable[U]]]): Observable[U]
EXPERIMENTAL Concatenates an Observable sequence of Observables eagerly into a single stream of values.
EXPERIMENTAL Concatenates an Observable sequence of Observables eagerly into a single stream of values.
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source Observables as they are observed. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Backpressure:
Backpressure is honored towards the downstream, however, due to the eagerness requirement, sources are subscribed to in unbounded mode and their values are queued up in an unbounded buffer.
Scheduler:
This method does not operate by default on a particular Scheduler.
- returns
an Observable that emits items all of the items emitted by the Observables emitted by
this, one after the other, without interleaving them
- Definition Classes
- Observable
- Annotations
- @Experimental()
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
-
def
concatEager[U >: T](that: Observable[U]): Observable[U]
EXPERIMENTAL Concatenates
thisandthatsource Observables eagerly into a single stream of values.EXPERIMENTAL Concatenates
thisandthatsource Observables eagerly into a single stream of values.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Backpressure:
Backpressure is honored towards the downstream, however, due to the eagerness requirement, sources are subscribed to in unbounded mode and their values are queued up in an unbounded buffer.
Scheduler:
This method does not operate by default on a particular Scheduler.
- that
the source to concat with.
- returns
an Observable that emits items all of the items emitted by
thisandthat, one after the other, without interleaving them.
- Definition Classes
- Observable
- Annotations
- @Experimental()
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
-
def
concatMap[R](f: (T) ⇒ Observable[R]): Observable[R]
Returns a new Observable that emits items resulting from applying a function that you supply to each item emitted by the source Observable, where that function returns an Observable, and then emitting the items that result from concatinating those resulting Observables.
Returns a new Observable that emits items resulting from applying a function that you supply to each item emitted by the source Observable, where that function returns an Observable, and then emitting the items that result from concatinating those resulting Observables.
- f
a function that, when applied to an item emitted by the source Observable, returns an Observable
- returns
an Observable that emits the result of applying the transformation function to each item emitted by the source Observable and concatinating the Observables obtained from this transformation
- Definition Classes
- Observable
-
def
concatMapEager[R](capacityHint: Int, maxConcurrent: Int, f: (T) ⇒ Observable[R]): Observable[R]
EXPERIMENTAL Maps a sequence of values into Observables and concatenates these Observables eagerly into a single Observable.
EXPERIMENTAL Maps a sequence of values into Observables and concatenates these Observables eagerly into a single Observable.
Eager concatenation means that once a Subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Backpressure:
Backpressure is honored towards the downstream, however, due to the eagerness requirement, sources are subscribed to in unbounded mode and their values are queued up in an unbounded buffer.
Scheduler:
This method does not operate by default on a particular Scheduler.
- capacityHint
hints about the number of expected source sequence values
- maxConcurrent
the maximum number of concurrent subscribed Observables
- f
the function that maps a sequence of values into a sequence of Observables that will be eagerly concatenated
- returns
an Observable that emits items all of the items emitted by the Observables returned by
f, one after the other, without interleaving them
- Definition Classes
- Observable
- Annotations
- @Experimental()
-
def
concatMapEager[R](capacityHint: Int, f: (T) ⇒ Observable[R]): Observable[R]
EXPERIMENTAL Maps a sequence of values into Observables and concatenates these Observables eagerly into a single Observable.
EXPERIMENTAL Maps a sequence of values into Observables and concatenates these Observables eagerly into a single Observable.
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Backpressure:
Backpressure is honored towards the downstream, however, due to the eagerness requirement, sources are subscribed to in unbounded mode and their values are queued up in an unbounded buffer.
Scheduler:
This method does not operate by default on a particular Scheduler.
- capacityHint
hints about the number of expected values in an Observable
- f
the function that maps a sequence of values into a sequence of Observables that will be eagerly concatenated
- returns
an Observable that emits items all of the items emitted by the Observables returned by
f, one after the other, without interleaving them
- Definition Classes
- Observable
- Annotations
- @Experimental()
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
-
def
concatMapEager[R](f: (T) ⇒ Observable[R]): Observable[R]
EXPERIMENTAL Maps a sequence of values into Observables and concatenates these Observables eagerly into a single Observable.
EXPERIMENTAL Maps a sequence of values into Observables and concatenates these Observables eagerly into a single Observable.
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Observables. The operator buffers the values emitted by these Observables and then drains them in order, each one after the previous one completes.
Backpressure:
Backpressure is honored towards the downstream, however, due to the eagerness requirement, sources are subscribed to in unbounded mode and their values are queued up in an unbounded buffer.
Scheduler:
This method does not operate by default on a particular Scheduler.
- f
the function that maps a sequence of values into a sequence of Observables that will be eagerly concatenated
- returns
an Observable that emits items all of the items emitted by the Observables returned by
f, one after the other, without interleaving them
- Definition Classes
- Observable
- Annotations
- @Experimental()
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
-
def
contains[U >: T](elem: U): Observable[Boolean]
Returns an Observable that emits a Boolean that indicates whether the source Observable emitted a specified item.
Returns an Observable that emits a Boolean that indicates whether the source Observable emitted a specified item.
Note: this method uses
==to compare elements. It's a bit different from RxJava which usesObject.equals.
- elem
the item to search for in the emissions from the source Observable
- returns
an Observable that emits
trueif the specified item is emitted by the source Observable, orfalseif the source Observable completes without emitting that item
- Definition Classes
- Observable
-
def
count(p: (T) ⇒ Boolean): Observable[Int]
Return an Observable which emits the number of elements in the source Observable which satisfy a predicate.
Return an Observable which emits the number of elements in the source Observable which satisfy a predicate.
- p
the predicate used to test elements.
- returns
an Observable which emits the number of elements in the source Observable which satisfy a predicate.
- Definition Classes
- Observable
-
def
countLong: Observable[Long]
Returns an Observable that counts the total number of items emitted by the source Observable and emits this count as a 64-bit Long.
Returns an Observable that counts the total number of items emitted by the source Observable and emits this count as a 64-bit Long.
<dl>
<dt>Backpressure Support:</dt>
- This operator does not support backpressure because by intent it will receive all values and reduce them to a single `onNext`.
<dt>Scheduler:</dt>- `countLong` does not operate by default on a particular `Scheduler`.
</dl>- returns
an Observable that emits a single item: the number of items emitted by the source Observable as a 64-bit Long item
- Definition Classes
- Observable
- See also
#count()
-
def
debounce(timeout: Duration, scheduler: Scheduler): Observable[T]
Debounces by dropping all values that are followed by newer values before the timeout value expires.
Debounces by dropping all values that are followed by newer values before the timeout value expires. The timer resets on each
onNextcall.NOTE: If events keep firing faster than the timeout then no data will be emitted.

Information on debounce vs throttle:
- timeout
The time each value has to be 'the most recent' of the rx.lang.scala.Observable to ensure that it's not dropped.
- scheduler
The rx.lang.scala.Scheduler to use internally to manage the timers which handle timeout for each event.
- returns
Observable which performs the throttle operation.
- Definition Classes
- Observable
- See also
Observable.throttleWithTimeout
-
def
debounce(timeout: Duration): Observable[T]
Debounces by dropping all values that are followed by newer values before the timeout value expires.
Debounces by dropping all values that are followed by newer values before the timeout value expires. The timer resets on each
onNextcall.NOTE: If events keep firing faster than the timeout then no data will be emitted.

Information on debounce vs throttle:
- timeout
The time each value has to be 'the most recent' of the rx.lang.scala.Observable to ensure that it's not dropped.
- returns
An rx.lang.scala.Observable which filters out values which are too quickly followed up with newer values.
- Definition Classes
- Observable
- See also
Observable.throttleWithTimeout
-
def
debounce(debounceSelector: (T) ⇒ Observable[Any]): Observable[T]
Return an Observable that mirrors the source Observable, except that it drops items emitted by the source Observable that are followed by another item within a computed debounce duration.
Return an Observable that mirrors the source Observable, except that it drops items emitted by the source Observable that are followed by another item within a computed debounce duration.
- debounceSelector
function to retrieve a sequence that indicates the throttle duration for each item
- returns
an Observable that omits items emitted by the source Observable that are followed by another item within a computed debounce duration
- Definition Classes
- Observable
-
def
delay(subscriptionDelay: () ⇒ Observable[Any], itemDelay: (T) ⇒ Observable[Any]): Observable[T]
Returns an Observable that delays the subscription to and emissions from the souce Observable via another Observable on a per-item basis.
Returns an Observable that delays the subscription to and emissions from the souce Observable via another Observable on a per-item basis.

Note: the resulting Observable will immediately propagate any
onErrornotification from the source Observable.- subscriptionDelay
a function that returns an Observable that triggers the subscription to the source Observable once it emits any item
- itemDelay
a function that returns an Observable for each item emitted by the source Observable, which is then used to delay the emission of that item by the resulting Observable until the Observable returned from
itemDelayemits an item- returns
an Observable that delays the subscription and emissions of the source Observable via another Observable on a per-item basis
- Definition Classes
- Observable
-
def
delay(itemDelay: (T) ⇒ Observable[Any]): Observable[T]
Returns an Observable that delays the emissions of the source Observable via another Observable on a per-item basis.
Returns an Observable that delays the emissions of the source Observable via another Observable on a per-item basis.

Note: the resulting Observable will immediately propagate any
onErrornotification from the source Observable.- itemDelay
a function that returns an Observable for each item emitted by the source Observable, which is then used to delay the emission of that item by the resulting Observable until the Observable returned from
itemDelayemits an item- returns
an Observable that delays the emissions of the source Observable via another Observable on a per-item basis
- Definition Classes
- Observable
-
def
delay(delay: Duration, scheduler: Scheduler): Observable[T]
Returns an Observable that emits the items emitted by the source Observable shifted forward in time by a specified delay.
Returns an Observable that emits the items emitted by the source Observable shifted forward in time by a specified delay. Error notifications from the source Observable are not delayed.
- delay
the delay to shift the source by
- scheduler
the Scheduler to use for delaying
- returns
the source Observable shifted in time by the specified delay
- Definition Classes
- Observable
-
def
delay(delay: Duration): Observable[T]
Returns an Observable that emits the items emitted by the source Observable shifted forward in time by a specified delay.
Returns an Observable that emits the items emitted by the source Observable shifted forward in time by a specified delay. Error notifications from the source Observable are not delayed.
- delay
the delay to shift the source by
- returns
the source Observable shifted in time by the specified delay
- Definition Classes
- Observable
-
def
delayError: ErrorDelayingObservable[T]
EXPERIMENTAL Converts an Observable into a ErrorDelayingObservable that provides operators which delay errors when composing multiple Observables.
EXPERIMENTAL Converts an Observable into a ErrorDelayingObservable that provides operators which delay errors when composing multiple Observables.
- Definition Classes
- Observable
- Annotations
- @Experimental()
-
def
delaySubscription(subscriptionDelay: () ⇒ Observable[Any]): Observable[T]
Returns an Observable that delays the subscription to the source Observable until a second Observable emits an item.
Returns an Observable that delays the subscription to the source Observable until a second Observable emits an item.
<dl>
<dt>Scheduler:</dt>
- This version of `delay` operates by default on the `computation` `Scheduler`.
</dl>- subscriptionDelay
a function that returns an Observable that triggers the subscription to the source Observable once it emits any item
- returns
an Observable that delays the subscription to the source Observable until the Observable returned by
subscriptionDelayemits an item
- Definition Classes
- Observable
- See also
-
def
delaySubscription(delay: Duration, scheduler: Scheduler): Observable[T]
Return an Observable that delays the subscription to the source Observable by a given amount of time, both waiting and subscribing on a given Scheduler.
Return an Observable that delays the subscription to the source Observable by a given amount of time, both waiting and subscribing on a given Scheduler.
- delay
the time to delay the subscription
- scheduler
the Scheduler on which the waiting and subscription will happen
- returns
an Observable that delays the subscription to the source Observable by a given amount, waiting and subscribing on the given Scheduler
- Definition Classes
- Observable
-
def
delaySubscription(delay: Duration): Observable[T]
Return an Observable that delays the subscription to the source Observable by a given amount of time.
Return an Observable that delays the subscription to the source Observable by a given amount of time.
- delay
the time to delay the subscription
- returns
an Observable that delays the subscription to the source Observable by the given amount
- Definition Classes
- Observable
-
def
dematerialize[U]: Observable[U]
[use case] Returns an Observable that reverses the effect of rx.lang.scala.Observable.materialize by transforming the rx.lang.scala.Notification objects emitted by the source Observable into the items or notifications they represent.
[use case]Returns an Observable that reverses the effect of rx.lang.scala.Observable.materialize by transforming the rx.lang.scala.Notification objects emitted by the source Observable into the items or notifications they represent.
This operation is only available if
thisis of typeObservable[Notification[U]]for someU, otherwise you will get a compilation error.
- returns
an Observable that emits the items and notifications embedded in the rx.lang.scala.Notification objects emitted by the source Observable
- Definition Classes
- Observable
Full Signaturedef dematerialize[U](implicit evidence: <:<[Observable[T], Observable[Notification[U]]]): Observable[U]
-
def
distinct[U](keySelector: (T) ⇒ U): Observable[T]
Returns an Observable that forwards all items emitted from the source Observable that are distinct according to a key selector function.
Returns an Observable that forwards all items emitted from the source Observable that are distinct according to a key selector function.
- keySelector
a function that projects an emitted item to a key value which is used for deciding whether an item is distinct from another one or not
- returns
an Observable of distinct items
- Definition Classes
- Observable
-
def
distinct: Observable[T]
Returns an Observable that forwards all distinct items emitted from the source Observable.
Returns an Observable that forwards all distinct items emitted from the source Observable.
- returns
an Observable of distinct items
- Definition Classes
- Observable
-
def
distinctUntilChanged[U](comparator: (T, T) ⇒ Boolean): Observable[T]
EXPERIMENTAL Returns an Observable that emits all items emitted by the source Observable that are distinct from their immediate predecessors when compared with each other via the provided comparator function.
EXPERIMENTAL Returns an Observable that emits all items emitted by the source Observable that are distinct from their immediate predecessors when compared with each other via the provided comparator function.

Backpressure:
The operator doesn't interfere with backpressure which is determined by the source Observable's backpressure behavior.
Scheduler:
This method does not operate by default on a particular Scheduler.
- comparator
the function that receives the previous item and the current item and is expected to return true if the two are equal, thus skipping the current value.
- returns
an Observable that emits those items from the source Observable that are distinct from their immediate predecessors
- Definition Classes
- Observable
- Annotations
- @Experimental()
- See also
-
def
distinctUntilChanged[U](keySelector: (T) ⇒ U): Observable[T]
Returns an Observable that forwards all items emitted from the source Observable that are sequentially distinct according to a key selector function.
Returns an Observable that forwards all items emitted from the source Observable that are sequentially distinct according to a key selector function.
- keySelector
a function that projects an emitted item to a key value which is used for deciding whether an item is sequentially distinct from another one or not
- returns
an Observable of sequentially distinct items
- Definition Classes
- Observable
-
def
distinctUntilChanged: Observable[T]
Returns an Observable that forwards all sequentially distinct items emitted from the source Observable.
Returns an Observable that forwards all sequentially distinct items emitted from the source Observable.
- returns
an Observable of sequentially distinct items
- Definition Classes
- Observable
-
def
doAfterTerminate(action: ⇒ Unit): Observable[T]
Registers an function to be called when this Observable invokes either onCompleted or onError.
Registers an function to be called when this Observable invokes either onCompleted or onError.

Scheduler:
This method does not operate by default on a particular Scheduler.
- action
an function to be invoked when the source Observable finishes
- returns
an Observable that emits the same items as the source Observable, then invokes the
action
- Definition Classes
- Observable
- See also
-
def
doOnCompleted(onCompleted: ⇒ Unit): Observable[T]
Invokes an action when the source Observable calls
onCompleted.Invokes an action when the source Observable calls
onCompleted.- onCompleted
the action to invoke when the source Observable calls
onCompleted- returns
the source Observable with the side-effecting behavior applied
- Definition Classes
- Observable
-
def
doOnEach(onNext: (T) ⇒ Unit, onError: (Throwable) ⇒ Unit, onCompleted: () ⇒ Unit): Observable[T]
Returns an Observable that applies the given function to each item emitted by an Observable.
Returns an Observable that applies the given function to each item emitted by an Observable.
- onNext
this function will be called whenever the Observable emits an item
- onError
this function will be called if an error occurs
- onCompleted
the action to invoke when the source Observable calls
- returns
an Observable with the side-effecting behavior applied.
- Definition Classes
- Observable
-
def
doOnEach(onNext: (T) ⇒ Unit, onError: (Throwable) ⇒ Unit): Observable[T]
Returns an Observable that applies the given function to each item emitted by an Observable.
Returns an Observable that applies the given function to each item emitted by an Observable.
- onNext
this function will be called whenever the Observable emits an item
- onError
this function will be called if an error occurs
- returns
an Observable with the side-effecting behavior applied.
- Definition Classes
- Observable
-
def
doOnEach(onNext: (T) ⇒ Unit): Observable[T]
Returns an Observable that applies the given function to each item emitted by an Observable.
Returns an Observable that applies the given function to each item emitted by an Observable.
- onNext
this function will be called whenever the Observable emits an item
- returns
an Observable with the side-effecting behavior applied.
- Definition Classes
- Observable
-
def
doOnEach(observer: Observer[T]): Observable[T]
Returns an Observable that applies the given function to each item emitted by an Observable.
Returns an Observable that applies the given function to each item emitted by an Observable.
- observer
the observer
- returns
an Observable with the side-effecting behavior applied.
- Definition Classes
- Observable
-
def
doOnError(onError: (Throwable) ⇒ Unit): Observable[T]
Invokes an action if the source Observable calls
onError.Invokes an action if the source Observable calls
onError.- onError
the action to invoke if the source Observable calls
onError- returns
the source Observable with the side-effecting behavior applied
- Definition Classes
- Observable
-
def
doOnNext(onNext: (T) ⇒ Unit): Observable[T]
Invokes an action when the source Observable calls
onNext.Invokes an action when the source Observable calls
onNext.- onNext
the action to invoke when the source Observable calls
onNext- returns
the source Observable with the side-effecting behavior applied
- Definition Classes
- Observable
-
def
doOnRequest(onRequest: (Long) ⇒ Unit): Observable[T]
BETA An Observable wrapping the source one that will invokes the given action when it receives a request for more items.
BETA An Observable wrapping the source one that will invokes the given action when it receives a request for more items.
Scheduler:
This method does not operate by default on a particular Scheduler.
- onRequest
the action that gets called when an Observer requests items from this Observable
- returns
an Observable that will call
onRequestwhen appropriate
- Definition Classes
- Observable
- Annotations
- @Beta()
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
- See also
-
def
doOnSubscribe(onSubscribe: ⇒ Unit): Observable[T]
Modifies the source
Observableso that it invokes the given action when it is subscribed from its subscribers.Modifies the source
Observableso that it invokes the given action when it is subscribed from its subscribers. Each subscription will result in an invocation of the given action except when the sourceObservableis reference counted, in which case the sourceObservablewill invoke the given action for the first subscription.
<dl>
<dt>Scheduler:</dt>
- `onSubscribe` does not operate by default on a particular `Scheduler`.
</dl>- onSubscribe
the action that gets called when an observer subscribes to this
Observable- returns
the source
Observablemodified so as to call this Action when appropriate
- Definition Classes
- Observable
- Since
0.20
- See also
-
def
doOnTerminate(onTerminate: ⇒ Unit): Observable[T]
Modifies an Observable so that it invokes an action when it calls
onCompletedoronError.Modifies an Observable so that it invokes an action when it calls
onCompletedoronError.
This differs from doAfterTerminate in that this happens **before** onCompleted/onError
are emitted.- onTerminate
the action to invoke when the source Observable calls
onCompletedoronError- returns
the source Observable with the side-effecting behavior applied
- Definition Classes
- Observable
- See also
-
def
doOnUnsubscribe(onUnsubscribe: ⇒ Unit): Observable[T]
Modifies the source
Observableso that it invokes the given action when it is unsubscribed from its subscribers.Modifies the source
Observableso that it invokes the given action when it is unsubscribed from its subscribers. Each un-subscription will result in an invocation of the given action except when the sourceObservableis reference counted, in which case the sourceObservablewill invoke the given action for the very last un-subscription.
<dl>
<dt>Scheduler:</dt>
- `doOnUnsubscribe` does not operate by default on a particular `Scheduler`.
</dl>- onUnsubscribe
the action that gets called when this
Observableis unsubscribed- returns
the source
Observablemodified so as to call this Action when appropriate
- Definition Classes
- Observable
- Since
0.20
- See also
-
def
drop(time: Duration, scheduler: Scheduler): Observable[T]
Returns an Observable that drops values emitted by the source Observable before a specified time window elapses.
Returns an Observable that drops values emitted by the source Observable before a specified time window elapses.
- time
the length of the time window to drop
- scheduler
the
Scheduleron which the timed wait happens- returns
an Observable that drops values emitted by the source Observable before the time window defined by
timeelapses and emits the remainder
- Definition Classes
- Observable
-
def
drop(time: Duration): Observable[T]
Returns an Observable that drops values emitted by the source Observable before a specified time window elapses.
Returns an Observable that drops values emitted by the source Observable before a specified time window elapses.
- time
the length of the time window to drop
- returns
an Observable that drops values emitted by the source Observable before the time window defined by
timeelapses and emits the remainder
- Definition Classes
- Observable
-
def
drop(n: Int): Observable[T]
Returns an Observable that skips the first
numitems emitted by the source Observable and emits the remainder.Returns an Observable that skips the first
numitems emitted by the source Observable and emits the remainder.
- n
the number of items to skip
- returns
an Observable that is identical to the source Observable except that it does not emit the first
numitems that the source emits
- Definition Classes
- Observable
-
def
dropRight(time: Duration, scheduler: Scheduler): Observable[T]
Returns an Observable that drops items emitted by the source Observable during a specified time window (defined on a specified scheduler) before the source completes.
Returns an Observable that drops items emitted by the source Observable during a specified time window (defined on a specified scheduler) before the source completes.

Note: this action will cache the latest items arriving in the specified time window.
- time
the length of the time window
- scheduler
the scheduler used as the time source
- returns
an Observable that drops those items emitted by the source Observable in a time window before the source completes defined by
timeandscheduler
- Definition Classes
- Observable
-
def
dropRight(time: Duration): Observable[T]
Returns an Observable that drops items emitted by the source Observable during a specified time window before the source completes.
Returns an Observable that drops items emitted by the source Observable during a specified time window before the source completes.

Note: this action will cache the latest items arriving in the specified time window.
- time
the length of the time window
- returns
an Observable that drops those items emitted by the source Observable in a time window before the source completes defined by
time
- Definition Classes
- Observable
-
def
dropRight(n: Int): Observable[T]
Returns an Observable that drops a specified number of items from the end of the sequence emitted by the source Observable.
Returns an Observable that drops a specified number of items from the end of the sequence emitted by the source Observable.

This Observer accumulates a queue long enough to store the first
nitems. As more items are received, items are taken from the front of the queue and emitted by the returned Observable. This causes such items to be delayed.- n
number of items to drop from the end of the source sequence
- returns
an Observable that emits the items emitted by the source Observable except for the dropped ones at the end
- Definition Classes
- Observable
- Exceptions thrown
java.lang.IndexOutOfBoundsExceptionifnis less than zero
-
def
dropUntil(other: Observable[Any]): Observable[T]
Returns an Observable that skips items emitted by the source Observable until a second Observable emits an item.
Returns an Observable that skips items emitted by the source Observable until a second Observable emits an item.
- other
the second Observable that has to emit an item before the source Observable's elements begin to be mirrored by the resulting Observable
- returns
an Observable that skips items from the source Observable until the second Observable emits an item, then emits the remaining items
- Definition Classes
- Observable
- See also
-
def
dropWhile(predicate: (T) ⇒ Boolean): Observable[T]
Returns an Observable that bypasses all items from the source Observable as long as the specified condition holds true.
Returns an Observable that bypasses all items from the source Observable as long as the specified condition holds true. Emits all further source items as soon as the condition becomes false.
- predicate
A function to test each item emitted from the source Observable for a condition.
- returns
an Observable that emits all items from the source Observable as soon as the condition becomes false.
- Definition Classes
- Observable
-
def
elementAt(index: Int): Observable[T]
Returns an Observable that emits the single item at a specified index in a sequence of emissions from a source Observbable.
Returns an Observable that emits the single item at a specified index in a sequence of emissions from a source Observbable.
- index
the zero-based index of the item to retrieve
- returns
an Observable that emits a single item: the item at the specified position in the sequence of those emitted by the source Observable
- Definition Classes
- Observable
- Exceptions thrown
java.lang.IndexOutOfBoundsExceptionif index is greater than or equal to the number of items emitted by the source Observable, or index is less than 0
-
def
elementAtOrDefault[U >: T](index: Int, default: U): Observable[U]
Returns an Observable that emits the item found at a specified index in a sequence of emissions from a source Observable, or a default item if that index is out of range.
Returns an Observable that emits the item found at a specified index in a sequence of emissions from a source Observable, or a default item if that index is out of range.
- index
the zero-based index of the item to retrieve
- default
the default item
- returns
an Observable that emits the item at the specified position in the sequence emitted by the source Observable, or the default item if that index is outside the bounds of the source sequence
- Definition Classes
- Observable
- Exceptions thrown
java.lang.IndexOutOfBoundsExceptionifindexis less than 0
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
exists(p: (T) ⇒ Boolean): Observable[Boolean]
Tests whether a predicate holds for some of the elements of this
Observable.Tests whether a predicate holds for some of the elements of this
Observable.- p
the predicate used to test elements.
- returns
an Observable emitting one single Boolean, which is
trueif the given predicatepholds for some of the elements of this Observable, andfalseotherwise.
- Definition Classes
- Observable
-
def
filter(predicate: (T) ⇒ Boolean): Observable[T]
Returns an Observable which only emits those items for which a given predicate holds.
Returns an Observable which only emits those items for which a given predicate holds.
- predicate
a function that evaluates the items emitted by the source Observable, returning
trueif they pass the filter- returns
an Observable that emits only those items in the original Observable that the filter evaluates as
true
- Definition Classes
- Observable
-
def
filterNot(p: (T) ⇒ Boolean): Observable[T]
Returns an Observable which only emits elements which do not satisfy a predicate.
Returns an Observable which only emits elements which do not satisfy a predicate.
- p
the predicate used to test elements.
- returns
Returns an Observable which only emits elements which do not satisfy a predicate.
- Definition Classes
- Observable
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
first: Observable[T]
Returns an Observable that emits only the very first item emitted by the source Observable, or raises an
NoSuchElementExceptionif the source Observable is empty.Returns an Observable that emits only the very first item emitted by the source Observable, or raises an
NoSuchElementExceptionif the source Observable is empty.
- returns
an Observable that emits only the very first item emitted by the source Observable, or raises an
NoSuchElementExceptionif the source Observable is empty
- Definition Classes
- Observable
- See also
"MSDN: Observable.firstAsync()"
-
def
firstOrElse[U >: T](default: ⇒ U): Observable[U]
Returns an Observable that emits only the very first item emitted by the source Observable, or a default value if the source Observable is empty.
Returns an Observable that emits only the very first item emitted by the source Observable, or a default value if the source Observable is empty.
- default
The default value to emit if the source Observable doesn't emit anything. This is a by-name parameter, so it is only evaluated if the source Observable doesn't emit anything.
- returns
an Observable that emits only the very first item from the source, or a default value if the source Observable completes without emitting any item.
- Definition Classes
- Observable
-
def
flatMap[R](maxConcurrent: Int, onNext: (T) ⇒ Observable[R], onError: (Throwable) ⇒ Observable[R], onCompleted: () ⇒ Observable[R]): Observable[R]
BETA Returns an Observable that applies a function to each item emitted or notification raised by the source Observable and then flattens the Observable s returned from these functions and emits the resulting items, while limiting the maximum number of concurrent subscriptions to these Observables.
BETA Returns an Observable that applies a function to each item emitted or notification raised by the source Observable and then flattens the Observable s returned from these functions and emits the resulting items, while limiting the maximum number of concurrent subscriptions to these Observables.
Scheduler:
This method does not operate by default on a particular Scheduler.
- maxConcurrent
the maximum number of Observables that may be subscribed to concurrently
- onNext
a function that returns an Observable to merge for each item emitted by the source Observable
- onError
a function that returns an Observable to merge for an onError notification from the source Observable
- onCompleted
a function that returns an Observable to merge for an onCompleted notification from the source Observable
- returns
an Observable that emits the results of merging the Observables returned from applying the specified functions to the emissions and notifications of the source Observable
- Definition Classes
- Observable
- Annotations
- @Beta()
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
- See also
-
def
flatMap[R](onNext: (T) ⇒ Observable[R], onError: (Throwable) ⇒ Observable[R], onCompleted: () ⇒ Observable[R]): Observable[R]
Returns an Observable that applies a function to each item emitted or notification raised by the source Observable and then flattens the Observables returned from these functions and emits the resulting items.
Returns an Observable that applies a function to each item emitted or notification raised by the source Observable and then flattens the Observables returned from these functions and emits the resulting items.
- R
the result type
- onNext
a function that returns an Observable to merge for each item emitted by the source Observable
- onError
a function that returns an Observable to merge for an onError notification from the source Observable
- onCompleted
a function that returns an Observable to merge for an onCompleted notification from the source Observable
- returns
an Observable that emits the results of merging the Observables returned from applying the specified functions to the emissions and notifications of the source Observable
- Definition Classes
- Observable
-
def
flatMap[R](maxConcurrent: Int, f: (T) ⇒ Observable[R]): Observable[R]
BETA Returns an Observable that emits items based on applying a function that you supply to each item emitted by the source Observable , where that function returns an Observable , and then merging those resulting Observables and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to these Observables.
BETA Returns an Observable that emits items based on applying a function that you supply to each item emitted by the source Observable , where that function returns an Observable , and then merging those resulting Observables and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to these Observables.
$$noDefaultScheduler
- maxConcurrent
the maximum number of Observables that may be subscribed to concurrently
- f
a function that, when applied to an item emitted by the source Observable, returns an Observable
- returns
an Observable that emits the result of applying the transformation function to each item emitted by the source Observable and merging the results of the Observables obtained from this transformation
- Definition Classes
- Observable
- Annotations
- @Beta()
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
- See also
-
def
flatMap[R](f: (T) ⇒ Observable[R]): Observable[R]
Creates a new Observable by applying a function that you supply to each item emitted by the source Observable, where that function returns an Observable, and then merging those resulting Observables and emitting the results of this merger.
Creates a new Observable by applying a function that you supply to each item emitted by the source Observable, where that function returns an Observable, and then merging those resulting Observables and emitting the results of this merger.
- f
a function that, when applied to an item emitted by the source Observable, returns an Observable
- returns
an Observable that emits the result of applying the transformation function to each item emitted by the source Observable and merging the results of the Observables obtained from this transformation.
- Definition Classes
- Observable
-
def
flatMapIterable[R](collectionSelector: (T) ⇒ Iterable[R]): Observable[R]
Returns an Observable that merges each item emitted by the source Observable with the values in an Iterable corresponding to that item that is generated by a selector.
Returns an Observable that merges each item emitted by the source Observable with the values in an Iterable corresponding to that item that is generated by a selector.
- R
the type of item emitted by the resulting Observable
- collectionSelector
a function that returns an Iterable sequence of values for when given an item emitted by the source Observable
- returns
an Observable that emits the results of merging the items emitted by the source Observable with the values in the Iterables corresponding to those items, as generated by
collectionSelector
- Definition Classes
- Observable
-
def
flatMapIterableWith[U, R](collectionSelector: (T) ⇒ Iterable[U])(resultSelector: (T, U) ⇒ R): Observable[R]
Returns an Observable that emits the results of applying a function to the pair of values from the source Observable and an Iterable corresponding to that item that is generated by a selector.
Returns an Observable that emits the results of applying a function to the pair of values from the source Observable and an Iterable corresponding to that item that is generated by a selector.
- U
the collection element type
- R
the type of item emited by the resulting Observable
- collectionSelector
a function that returns an Iterable sequence of values for each item emitted by the source Observable
- resultSelector
a function that returns an item based on the item emitted by the source Observable and the Iterable returned for that item by the
collectionSelector- returns
an Observable that emits the items returned by
resultSelectorfor each item in the source Observable
- Definition Classes
- Observable
-
def
flatMapWith[U, R](maxConcurrent: Int, collectionSelector: (T) ⇒ Observable[U])(resultSelector: (T, U) ⇒ R): Observable[R]
BETA Returns an Observable that emits the results of a specified function to the pair of values emitted by the source Observable and a specified collection Observable.
BETA Returns an Observable that emits the results of a specified function to the pair of values emitted by the source Observable and a specified collection Observable.
- U
the type of items emitted by the collection Observable
- R
the type of items emitted by the resulting Observable
- maxConcurrent
the maximum number of Observables that may be subscribed to concurrently
- collectionSelector
a function that returns an Observable for each item emitted by the source Observable
- resultSelector
a function that combines one item emitted by each of the source and collection Observables and returns an item to be emitted by the resulting Observable
- returns
an Observable that emits the results of applying a function to a pair of values emitted by the source Observable and the collection Observable
- Definition Classes
- Observable
- Annotations
- @Beta()
-
def
flatMapWith[U, R](collectionSelector: (T) ⇒ Observable[U])(resultSelector: (T, U) ⇒ R): Observable[R]
Returns an Observable that emits the results of a specified function to the pair of values emitted by the source Observable and a specified collection Observable.
Returns an Observable that emits the results of a specified function to the pair of values emitted by the source Observable and a specified collection Observable.
- U
the type of items emitted by the collection Observable
- R
the type of items emitted by the resulting Observable
- collectionSelector
a function that returns an Observable for each item emitted by the source Observable
- resultSelector
a function that combines one item emitted by each of the source and collection Observables and returns an item to be emitted by the resulting Observable
- returns
an Observable that emits the results of applying a function to a pair of values emitted by the source Observable and the collection Observable
- Definition Classes
- Observable
-
def
flatten[U](maxConcurrent: Int)(implicit evidence: <:<[Observable[T], Observable[Observable[U]]]): Observable[U]
Flattens an Observable that emits Observables into a single Observable that emits the items emitted by those Observables, without any transformation, while limiting the maximum number of concurrent subscriptions to these Observables.
Flattens an Observable that emits Observables into a single Observable that emits the items emitted by those Observables, without any transformation, while limiting the maximum number of concurrent subscriptions to these Observables.

You can combine the items emitted by multiple Observables so that they appear as a single Observable, by using the
flattenmethod.- maxConcurrent
the maximum number of Observables that may be subscribed to concurrently
- returns
an Observable that emits items that are the result of flattening the Observables emitted by the
sourceObservable
- Definition Classes
- Observable
- Exceptions thrown
java.lang.IllegalArgumentExceptionifmaxConcurrentis less than or equal to 0
-
def
flatten[U]: Observable[U]
[use case] Flattens the sequence of Observables emitted by
thisinto one Observable, without any transformation.[use case]Flattens the sequence of Observables emitted by
thisinto one Observable, without any transformation.
You can combine the items emitted by multiple Observables so that they act like a single Observable by using this method.
This operation is only available if
thisis of typeObservable[Observable[U]]for someU, otherwise you'll get a compilation error.- returns
an Observable that emits items that are the result of flattening the items emitted by the Observables emitted by
this
- Definition Classes
- Observable
Full Signaturedef flatten[U](implicit evidence: <:<[Observable[T], Observable[Observable[U]]]): Observable[U]
-
def
foldLeft[R](initialValue: R)(accumulator: (R, T) ⇒ R): Observable[R]
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, then feeds the result of that function along with the second item emitted by an Observable into the same function, and so on until all items have been emitted by the source Observable, emitting the final result from the final call to your function as its sole item.
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, then feeds the result of that function along with the second item emitted by an Observable into the same function, and so on until all items have been emitted by the source Observable, emitting the final result from the final call to your function as its sole item.

This technique, which is called "reduce" or "aggregate" here, is sometimes called "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has an
injectmethod that does a similar operation on lists.- initialValue
the initial (seed) accumulator value
- accumulator
an accumulator function to be invoked on each item emitted by the source Observable, the result of which will be used in the next accumulator call
- returns
an Observable that emits a single item that is the result of accumulating the output from the items emitted by the source Observable
- Definition Classes
- Observable
-
def
forall(predicate: (T) ⇒ Boolean): Observable[Boolean]
Returns an Observable that emits a Boolean that indicates whether all of the items emitted by the source Observable satisfy a condition.
Returns an Observable that emits a Boolean that indicates whether all of the items emitted by the source Observable satisfy a condition.
- predicate
a function that evaluates an item and returns a Boolean
- returns
an Observable that emits
trueif all items emitted by the source Observable satisfy the predicate; otherwise,false
- Definition Classes
- Observable
-
def
foreach(onNext: (T) ⇒ Unit, onError: (Throwable) ⇒ Unit, onComplete: () ⇒ Unit): Unit
Subscribes to the Observable and receives notifications for each element and the terminal events.
Subscribes to the Observable and receives notifications for each element and the terminal events.
Alias to
subscribe(T => Unit, Throwable => Unit, () => Unit).Scheduler:
This method does not operate by default on a particular Scheduler.
- onNext
function to execute for each item.
- onError
function to execute when an error is emitted.
- onComplete
function to execute when completion is signalled.
- Definition Classes
- Observable
- Since
0.19
- Exceptions thrown
java.lang.IllegalArgumentExceptionifonNextis null, or ifonErroris null, or ifonCompleteis null- See also
-
def
foreach(onNext: (T) ⇒ Unit, onError: (Throwable) ⇒ Unit): Unit
Subscribes to the Observable and receives notifications for each element and error events.
Subscribes to the Observable and receives notifications for each element and error events.
Alias to
subscribe(T => Unit, Throwable => Unit).Scheduler:
This method does not operate by default on a particular Scheduler.
- onNext
function to execute for each item.
- onError
function to execute when an error is emitted.
- Definition Classes
- Observable
- Since
0.19
- Exceptions thrown
java.lang.IllegalArgumentExceptionifonNextis null, or ifonErroris null- See also
-
def
foreach(onNext: (T) ⇒ Unit): Unit
Subscribes to the Observable and receives notifications for each element.
Subscribes to the Observable and receives notifications for each element.
Alias to
subscribe(T => Unit).Scheduler:
This method does not operate by default on a particular Scheduler.
- onNext
function to execute for each item.
- Definition Classes
- Observable
- Since
0.19
- Exceptions thrown
java.lang.IllegalArgumentExceptionifonNextis nullrx.exceptions.OnErrorNotImplementedExceptionif the Observable tries to callonError- See also
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
groupBy[K, V](keySelector: (T) ⇒ K, valueSelector: (T) ⇒ V): Observable[(K, Observable[V])]
Groups the items emitted by an Observable according to a specified criterion, and emits these grouped items as
(key, observable)pairs.Groups the items emitted by an Observable according to a specified criterion, and emits these grouped items as
(key, observable)pairs.
Note: A
(key, observable)will cache the items it is to emit until such time as it is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore those(key, observable)pairs that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator liketake(0)to them.Backpressure Support:
This operator does not support backpressure as splitting a stream effectively turns it into a "hot observable" and blocking any one group would block the entire parent stream. If you need backpressure on individual groups then you should use operators such as
nBackpressureDropor@link #onBackpressureBuffer. ===Scheduler:=== groupBy` does not operate by default on a particular `Scheduler`.- K
the key type
- V
the value type
- keySelector
a function that extracts the key for each item
- valueSelector
a function that extracts the return element for each item
- returns
an Observable that emits
(key, observable)pairs, each of which corresponds to a unique key value and each of which emits those items from the source Observable that share that key value
- Definition Classes
- Observable
- See also
-
def
groupBy[K](f: (T) ⇒ K): Observable[(K, Observable[T])]
Groups the items emitted by this Observable according to a specified discriminator function.
Groups the items emitted by this Observable according to a specified discriminator function.
- K
the type of keys returned by the discriminator function.
- f
a function that extracts the key from an item
- returns
an Observable that emits
(key, observable)pairs, whereobservablecontains all items for whichfreturnedkey.
- Definition Classes
- Observable
-
def
groupJoin[S, R](other: Observable[S])(leftDuration: (T) ⇒ Observable[Any], rightDuration: (S) ⇒ Observable[Any], resultSelector: (T, Observable[S]) ⇒ R): Observable[R]
Returns an Observable that correlates two Observables when they overlap in time and groups the results.
Returns an Observable that correlates two Observables when they overlap in time and groups the results.
- other
the other Observable to correlate items from the source Observable with
- leftDuration
a function that returns an Observable whose emissions indicate the duration of the values of the source Observable
- rightDuration
a function that returns an Observable whose emissions indicate the duration of the values of the
otherObservable- resultSelector
a function that takes an item emitted by each Observable and returns the value to be emitted by the resulting Observable
- returns
an Observable that emits items based on combining those items emitted by the source Observables whose durations overlap
- Definition Classes
- Observable
-
def
hasObservers: Boolean
Indicates whether the Subject has Observers subscribed to it.
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
def
head: Observable[T]
Returns an Observable that emits only the very first item emitted by the source Observable, or raises an
NoSuchElementExceptionif the source Observable is empty.Returns an Observable that emits only the very first item emitted by the source Observable, or raises an
NoSuchElementExceptionif the source Observable is empty.
- returns
an Observable that emits only the very first item emitted by the source Observable, or raises an
NoSuchElementExceptionif the source Observable is empty
- Definition Classes
- Observable
- See also
"MSDN: Observable.firstAsync()"
-
def
headOption: Observable[Option[T]]
Returns an Observable that emits only an
Optionwith the very first item emitted by the source Observable, orNoneif the source Observable is empty.Returns an Observable that emits only an
Optionwith the very first item emitted by the source Observable, orNoneif the source Observable is empty.
- returns
an Observable that emits only an
Optionwith the very first item from the source, orNoneif the source Observable completes without emitting any item.
- Definition Classes
- Observable
-
def
headOrElse[U >: T](default: ⇒ U): Observable[U]
Returns an Observable that emits only the very first item emitted by the source Observable, or a default value if the source Observable is empty.
Returns an Observable that emits only the very first item emitted by the source Observable, or a default value if the source Observable is empty.
- default
The default value to emit if the source Observable doesn't emit anything. This is a by-name parameter, so it is only evaluated if the source Observable doesn't emit anything.
- returns
an Observable that emits only the very first item from the source, or a default value if the source Observable completes without emitting any item.
- Definition Classes
- Observable
-
def
isEmpty: Observable[Boolean]
Tests whether this
Observableemits no elements.Tests whether this
Observableemits no elements.- returns
an Observable emitting one single Boolean, which is
trueif thisObservableemits no elements, andfalseotherwise.
- Definition Classes
- Observable
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
join[S, R](other: Observable[S])(leftDurationSelector: (T) ⇒ Observable[Any], rightDurationSelector: (S) ⇒ Observable[Any], resultSelector: (T, S) ⇒ R): Observable[R]
Correlates the items emitted by two Observables based on overlapping durations.
Correlates the items emitted by two Observables based on overlapping durations.
- other
the second Observable to join items from
- leftDurationSelector
a function to select a duration for each item emitted by the source Observable, used to determine overlap
- rightDurationSelector
a function to select a duration for each item emitted by the inner Observable, used to determine overlap
- resultSelector
a function that computes an item to be emitted by the resulting Observable for any two overlapping items emitted by the two Observables
- returns
an Observable that emits items correlating to items emitted by the source Observables that have overlapping durations
- Definition Classes
- Observable
- See also
-
def
last: Observable[T]
Returns an Observable that emits the last item emitted by the source Observable or notifies observers of an
NoSuchElementExceptionif the source Observable is empty.Returns an Observable that emits the last item emitted by the source Observable or notifies observers of an
NoSuchElementExceptionif the source Observable is empty.
- returns
an Observable that emits the last item from the source Observable or notifies observers of an error
- Definition Classes
- Observable
- See also
"MSDN: Observable.lastAsync()"
-
def
lastOption: Observable[Option[T]]
Returns an Observable that emits only an
Optionwith the last item emitted by the source Observable, orNoneif the source Observable completes without emitting any items.Returns an Observable that emits only an
Optionwith the last item emitted by the source Observable, orNoneif the source Observable completes without emitting any items.
- returns
an Observable that emits only an
Optionwith the last item emitted by the source Observable, orNoneif the source Observable is empty
- Definition Classes
- Observable
-
def
lastOrElse[U >: T](default: ⇒ U): Observable[U]
Returns an Observable that emits only the last item emitted by the source Observable, or a default item if the source Observable completes without emitting any items.
Returns an Observable that emits only the last item emitted by the source Observable, or a default item if the source Observable completes without emitting any items.
- default
the default item to emit if the source Observable is empty. This is a by-name parameter, so it is only evaluated if the source Observable doesn't emit anything.
- returns
an Observable that emits only the last item emitted by the source Observable, or a default item if the source Observable is empty
- Definition Classes
- Observable
-
def
length: Observable[Int]
Returns an Observable that counts the total number of elements in the source Observable.
Returns an Observable that counts the total number of elements in the source Observable.
- returns
an Observable emitting the number of counted elements of the source Observable as its single item.
- Definition Classes
- Observable
-
def
lift[R](operator: (Subscriber[R]) ⇒ Subscriber[T]): Observable[R]
Lifts a function to the current Observable and returns a new Observable that when subscribed to will pass the values of the current Observable through the Operator function.
Lifts a function to the current Observable and returns a new Observable that when subscribed to will pass the values of the current Observable through the Operator function.
In other words, this allows chaining Observers together on an Observable for acting on the values within the Observable.
observable.map(...).filter(...).take(5).lift(new OperatorA()).lift(new OperatorB(...)).subscribe()
If the operator you are creating is designed to act on the individual items emitted by a source Observable, use
lift. If your operator is designed to transform the source Observable as a whole (for instance, by applying a particular set of existing RxJava operators to it) use#compose. <dl> <dt>Scheduler:</dt>- `lift` does not operate by default on a particular [[Scheduler]].
</dl>- operator
the Operator that implements the Observable-operating function to be applied to the source Observable
- returns
an Observable that is the result of applying the lifted Operator to the source Observable
- Definition Classes
- Observable
- Since
0.17
- See also
-
def
map[R](func: (T) ⇒ R): Observable[R]
Returns an Observable that applies the given function to each item emitted by an Observable and emits the result.
Returns an Observable that applies the given function to each item emitted by an Observable and emits the result.
- func
a function to apply to each item emitted by the Observable
- returns
an Observable that emits the items from the source Observable, transformed by the given function
- Definition Classes
- Observable
-
def
materialize: Observable[Notification[T]]
Turns all of the notifications from a source Observable into onNext emissions, and marks them with their original notification types within rx.lang.scala.Notification objects.
Turns all of the notifications from a source Observable into onNext emissions, and marks them with their original notification types within rx.lang.scala.Notification objects.
- returns
an Observable whose items are the result of materializing the items and notifications of the source Observable
- Definition Classes
- Observable
-
def
merge[U >: T](that: Observable[U]): Observable[U]
Flattens two Observables into one Observable, without any transformation.
Flattens two Observables into one Observable, without any transformation.

You can combine items emitted by two Observables so that they act like a single Observable by using the
mergemethod.- that
an Observable to be merged
- returns
an Observable that emits items from
thisandthatuntilthisorthatemitsonErroror both Observables emitonCompleted.
- Definition Classes
- Observable
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
nest: Observable[Observable[T]]
Converts the source
Observable[T]into anObservable[Observable[T]]that emits the source Observable as its single emission.Converts the source
Observable[T]into anObservable[Observable[T]]that emits the source Observable as its single emission.
- returns
an Observable that emits a single item: the source Observable
- Definition Classes
- Observable
-
def
nonEmpty: Observable[Boolean]
Return an Observable emitting one single
Boolean, which istrueif the source Observable emits any element, andfalseotherwise.Return an Observable emitting one single
Boolean, which istrueif the source Observable emits any element, andfalseotherwise.- returns
an Observable emitting one single Boolean
, which istrueif the source Observable emits any element, andfalse otherwise.
- Definition Classes
- Observable
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
observeOn(scheduler: Scheduler, delayError: Boolean, bufferSize: Int): Observable[T]
Returns an Observable to perform its emissions and notifications on a specified
Scheduler, asynchronously with a bounded buffer of configurable size and optionally delaysonErrornotifications.Returns an Observable to perform its emissions and notifications on a specified
Scheduler, asynchronously with a bounded buffer of configurable size and optionally delaysonErrornotifications.
Scheduler:
you specify which Scheduler this operator will use
- scheduler
- delayError
indicates if the
onErrornotification may not cut ahead ofonNextnotification on the other side of the scheduling boundary. If true a sequence ending in onError will be replayed in the same order as was received from upstream- bufferSize
the size of the buffer
- returns
the source Observable modified so that its Observers are notified on the specified Scheduler
- Definition Classes
- Observable
- See also
-
def
observeOn(scheduler: Scheduler, bufferSize: Int): Observable[T]
REturns an Observable to perform its emissions and notifications on a specified Scheduler, asynchronously with a bounded buffer of configurable size.
REturns an Observable to perform its emissions and notifications on a specified Scheduler, asynchronously with a bounded buffer of configurable size.
Note that
onErrornotifications will cut ahead ofonNextnotifications on the emission thread if Scheduler is truly asynchronous. If strict event ordering is required, consider using the Observable.observeOn(scheduler:rx\.lang\.scala\.Scheduler,delayError:Boolean)* overload.
Scheduler:
you specify which Scheduler this operator will use
- scheduler
- bufferSize
the size of the buffer.
- returns
the source Observable modified so that its Observers are notified on the specified Scheduler
- Definition Classes
- Observable
- See also
-
def
observeOn(scheduler: Scheduler, delayError: Boolean): Observable[T]
Return an Observable to perform its emissions and notifications on a specified Scheduler, asynchronously with a bounded buffer and optionally delays onError notifications.
Return an Observable to perform its emissions and notifications on a specified Scheduler, asynchronously with a bounded buffer and optionally delays onError notifications.

Scheduler:
you specify which Scheduler this operator will use
- scheduler
- delayError
indicates if the onError notification may not cut ahead of onNext notification on the other side of the scheduling boundary. If true a sequence ending in onError will be replayed in the same order as was received from upstream
- returns
the source Observable that its Observers are notified on the specified Scheduler
- Definition Classes
- Observable
- See also
-
def
observeOn(scheduler: Scheduler): Observable[T]
Asynchronously notify rx.lang.scala.Observers on the specified rx.lang.scala.Scheduler.
Asynchronously notify rx.lang.scala.Observers on the specified rx.lang.scala.Scheduler.
- scheduler
the rx.lang.scala.Scheduler to notify rx.lang.scala.Observers on
- returns
the source Observable modified so that its rx.lang.scala.Observers are notified on the specified rx.lang.scala.Scheduler
- Definition Classes
- Observable
-
def
onBackpressureBuffer(capacity: Long, onOverflow: ⇒ Unit): Observable[T]
BETA Instructs an Observable that is emitting items faster than its Observer can consume them to buffer up to a given amount of items until they can be emitted.
BETA Instructs an Observable that is emitting items faster than its Observer can consume them to buffer up to a given amount of items until they can be emitted. The resulting Observable will emit
BufferOverflowExceptionas soon as the buffer's capacity is exceeded, drop all undelivered items, unsubscribe from the source, and notifyonOverflow.
Scheduler:
This method does not operate by default on a particular Scheduler.
- capacity
capacity of the internal buffer.
- onOverflow
an action to run when the buffer's capacity is exceeded. This is a by-name parameter.
- returns
the source Observable modified to buffer items up to the given capacity
- Definition Classes
- Observable
- Annotations
- @Beta()
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
- See also
-
def
onBackpressureBuffer(capacity: Long): Observable[T]
BETA Instructs an Observable that is emitting items faster than its Observer can consume them to buffer up to a given amount of items until they can be emitted.
BETA Instructs an Observable that is emitting items faster than its Observer can consume them to buffer up to a given amount of items until they can be emitted. The resulting Observable will emit
BufferOverflowExceptionas soon as the buffer's capacity is exceeded, drop all undelivered items, and unsubscribe from the source.
Scheduler:
This method does not operate by default on a particular Scheduler.
- capacity
capacity of the internal buffer.
- returns
an Observable that will buffer items up to the given capacity
- Definition Classes
- Observable
- Annotations
- @Beta()
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
- See also
-
def
onBackpressureBuffer: Observable[T]
Instructs an Observable that is emitting items faster than its observer can consume them to buffer these items indefinitely until they can be emitted.
Instructs an Observable that is emitting items faster than its observer can consume them to buffer these items indefinitely until they can be emitted.

Scheduler:
onBackpressureBufferdoes not operate by default on a particularScheduler.- returns
the source Observable modified to buffer items to the extent system resources allow
- Definition Classes
- Observable
- See also
-
def
onBackpressureDrop(onDrop: (T) ⇒ Unit): Observable[T]
EXPERIMENTAL Instructs an Observable that is emitting items faster than its observer can consume them to discard, rather than emit, those items that its observer is not prepared to observe.
EXPERIMENTAL Instructs an Observable that is emitting items faster than its observer can consume them to discard, rather than emit, those items that its observer is not prepared to observe.

If the downstream request count hits
0then the Observable will refrain from callingonNextuntil the observer invokesrequest(n)again to increase the request count.Scheduler:
This method does not operate by default on a particular Scheduler.
- onDrop
the action to invoke for each item dropped.
onDropaction should be fast and should never block.- returns
an new Observable that will drop
onNextnotifications on overflow
- Definition Classes
- Observable
- Annotations
- @Experimental()
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
- See also
-
def
onBackpressureDrop: Observable[T]
Use this operator when the upstream does not natively support backpressure and you wish to drop
onNextwhen unable to handle further events.Use this operator when the upstream does not natively support backpressure and you wish to drop
onNextwhen unable to handle further events.
If the downstream request count hits 0 then
onNextwill be dropped untilrequest(long n)is invoked again to increase the request count.Scheduler:
onBackpressureDrop
does not operate by default on a particularScheduler.- returns
the source Observable modified to drop
onNextnotifications on overflow
- Definition Classes
- Observable
- See also
-
def
onBackpressureLatest: Observable[T]
EXPERIMENTAL Instructs an Observable that is emitting items faster than its observer can consume them to hold onto the latest value and emit that on request.
EXPERIMENTAL Instructs an Observable that is emitting items faster than its observer can consume them to hold onto the latest value and emit that on request.

Its behavior is logically equivalent to
toBlocking().latest()with the exception that the downstream is not blocking while requesting more values.Note that if the upstream Observable does support backpressure, this operator ignores that capability and doesn't propagate any backpressure requests from downstream.
Note that due to the nature of how backpressure requests are propagated through subscribeOn/observeOn, requesting more than 1 from downstream doesn't guarantee a continuous delivery of onNext events.
- returns
the source Observable modified so that it emits the most recently-received item upon request
- Definition Classes
- Observable
- Annotations
- @Experimental()
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
-
def
onCompleted(): Unit
Notifies the Observer that the rx.lang.scala.Observable has finished sending push-based notifications.
Notifies the Observer that the rx.lang.scala.Observable has finished sending push-based notifications.
The rx.lang.scala.Observable will not call this method if it calls
onError. -
def
onError(error: Throwable): Unit
Notifies the Observer that the rx.lang.scala.Observable has experienced an error condition.
Notifies the Observer that the rx.lang.scala.Observable has experienced an error condition.
If the rx.lang.scala.Observable calls this method, it will not thereafter call
onNextoronCompleted. -
def
onErrorResumeNext[U >: T](resumeFunction: (Throwable) ⇒ Observable[U]): Observable[U]
Instruct an Observable to pass control to another Observable rather than invoking onError if it encounters an error.
Instruct an Observable to pass control to another Observable rather than invoking onError if it encounters an error.

By default, when an Observable encounters an error that prevents it from emitting the expected item to its rx.lang.scala.Observer, the Observable invokes its Observer's
onErrormethod, and then quits without invoking any more of its Observer's methods. TheonErrorResumeNextmethod changes this behavior. If you pass a function that returns an Observable (resumeFunction) toonErrorResumeNext, if the original Observable encounters an error, instead of invoking its Observer'sonErrormethod, it will instead relinquish control to the Observable returned fromresumeFunction, which will invoke the Observer's onNext method if it is able to do so. In such a case, because no Observable necessarily invokesonError, the Observer may never know that an error happened.You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
- resumeFunction
a function that returns an Observable that will take over if the source Observable encounters an error
- returns
the original Observable, with appropriately modified behavior
- Definition Classes
- Observable
-
def
onErrorReturn[U >: T](resumeFunction: (Throwable) ⇒ U): Observable[U]
Instruct an Observable to emit an item (returned by a specified function) rather than invoking onError if it encounters an error.
Instruct an Observable to emit an item (returned by a specified function) rather than invoking onError if it encounters an error.

By default, when an Observable encounters an error that prevents it from emitting the expected item to its rx.lang.scala.Observer, the Observable invokes its Observer's
onErrormethod, and then quits without invoking any more of its Observer's methods. TheonErrorReturnmethod changes this behavior. If you pass a function (resumeFunction) to an Observable'sonErrorReturnmethod, if the original Observable encounters an error, instead of invoking its Observer'sonErrormethod, it will instead pass the return value ofresumeFunctionto the Observer's onNext method.You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
- resumeFunction
a function that returns an item that the new Observable will emit if the source Observable encounters an error
- returns
the original Observable with appropriately modified behavior
- Definition Classes
- Observable
-
def
onExceptionResumeNext[U >: T](resumeSequence: Observable[U]): Observable[U]
Instruct an Observable to pass control to another Observable rather than invoking onError if it encounters an error of type
java.lang.Exception.Instruct an Observable to pass control to another Observable rather than invoking onError if it encounters an error of type
java.lang.Exception.This differs from
Observable.onErrorResumeNextin that this one does not handlejava.lang.Throwableorjava.lang.Errorbut lets those continue through.
By default, when an Observable encounters an error that prevents it from emitting the expected item to its rx.lang.scala.Observer, the Observable invokes its Observer's
onErrormethod, and then quits without invoking any more of its Observer's methods. TheonErrorResumeNextmethod changes this behavior. If you pass another Observable (resumeSequence) to an Observable'sonErrorResumeNextmethod, if the original Observable encounters an error, instead of invoking its Observer'sonErrormethod, it will instead relinquish control toresumeSequencewhich will invoke the Observer's onNext method if it is able to do so. In such a case, because no Observable necessarily invokesonError, the Observer may never know that an error happened.You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
- resumeSequence
a function that returns an Observable that will take over if the source Observable encounters an error
- returns
the original Observable, with appropriately modified behavior
- Definition Classes
- Observable
-
def
onNext(value: T): Unit
Provides the Observer with new data.
Provides the Observer with new data.
The rx.lang.scala.Observable calls this closure 0 or more times.
The rx.lang.scala.Observable will not call this method again after it calls either
onCompletedoronError. -
def
onTerminateDetach: Observable[T]
EXPERIMENTAL Return a new Observable that will null out references to the upstream Producer and downstream Subscriber if the sequence is terminated or downstream unsubscribes.
EXPERIMENTAL Return a new Observable that will null out references to the upstream Producer and downstream Subscriber if the sequence is terminated or downstream unsubscribes.
Backpressure:
Fully supports backpressure.
Scheduler:
This method does not operate by default on a particular Scheduler.
- returns
an Observable which out references to the upstream Producer and downstream Subscriber if the sequence is terminated or downstream unsubscribes
- Definition Classes
- Observable
- Annotations
- @Experimental()
-
def
orElse[U >: T](default: ⇒ U): Observable[U]
Returns an Observable that emits the items emitted by the source Observable or a specified default item if the source Observable is empty.
Returns an Observable that emits the items emitted by the source Observable or a specified default item if the source Observable is empty.
- default
the item to emit if the source Observable emits no items. This is a by-name parameter, so it is only evaluated if the source Observable doesn't emit anything.
- returns
an Observable that emits either the specified default item if the source Observable emits no items, or the items emitted by the source Observable
- Definition Classes
- Observable
-
def
product: Observable[T]
[use case] Returns an Observable that multiplies up the elements of this Observable.
[use case]Returns an Observable that multiplies up the elements of this Observable.
This operation is only available if the elements of this Observable are numbers, otherwise you will get a compilation error.
- returns
an Observable emitting the product of all the elements of the source Observable as its single item.
- Definition Classes
- Observable
Full Signaturedef product[U >: T](implicit num: Numeric[U]): Observable[U]
-
def
publish[R](selector: (Observable[T]) ⇒ Observable[R]): Observable[R]
Returns an Observable that emits the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the underlying sequence.Returns an Observable that emits the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the underlying sequence.
- selector
a function that can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all notifications of the source from the time of the subscription forward.
- returns
an Observable that emits the results of invoking the selector on the items emitted by a
ConnectableObservablethat shares a single subscription to the underlying sequence
- Definition Classes
- Observable
-
def
publish: ConnectableObservable[T]
Returns a rx.lang.scala.observables.ConnectableObservable, which waits until the
connectfunction is called before it begins emitting items fromthisrx.lang.scala.Observable to those rx.lang.scala.Observers that have subscribed to it.Returns a rx.lang.scala.observables.ConnectableObservable, which waits until the
connectfunction is called before it begins emitting items fromthisrx.lang.scala.Observable to those rx.lang.scala.Observers that have subscribed to it.
- Definition Classes
- Observable
-
def
rebatchRequests(n: Int): Observable[T]
EXPERIMENTAL Returns an Observable that requests
ninitially from the upstream and then 75% ofnsubsequently after 75% ofnvalues have been emitted to the downstream.EXPERIMENTAL Returns an Observable that requests
ninitially from the upstream and then 75% ofnsubsequently after 75% ofnvalues have been emitted to the downstream.This operator allows preventing the downstream to trigger unbounded mode via
request(Long.MaxValue)or compensate for the per-item overhead of small and frequent requests.Backpressure:
The operator expects backpressure from upstream and honors backpressure from downstream. ===Scheduler:=== This method does not operate by default on a particular [[Scheduler]].
- n
the initial request amount, further request will happen after 75% of this value
- returns
the Observable that rebatches request amounts from downstream
- Definition Classes
- Observable
- Annotations
- @Experimental()
-
def
reduce[U >: T](accumulator: (U, U) ⇒ U): Observable[U]
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, then feeds the result of that function along with the second item emitted by the source Observable into the same function, and so on until all items have been emitted by the source Observable, and emits the final result from the final call to your function as its sole item.
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, then feeds the result of that function along with the second item emitted by the source Observable into the same function, and so on until all items have been emitted by the source Observable, and emits the final result from the final call to your function as its sole item.

This technique, which is called "reduce" or "aggregate" here, is sometimes called "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has an
injectmethod that does a similar operation on lists.- accumulator
An accumulator function to be invoked on each item emitted by the source Observable, whose result will be used in the next accumulator call
- returns
an Observable that emits a single item that is the result of accumulating the output from the source Observable
- Definition Classes
- Observable
-
def
repeat(count: Long, scheduler: Scheduler): Observable[T]
Returns an Observable that repeats the sequence of items emitted by the source Observable at most
counttimes, on a particular Scheduler.Returns an Observable that repeats the sequence of items emitted by the source Observable at most
counttimes, on a particular Scheduler.
- count
the number of times the source Observable items are repeated, a count of 0 will yield an empty sequence
- scheduler
the
Schedulerto emit the items on- returns
an Observable that repeats the sequence of items emitted by the source Observable at most
counttimes on a particular Scheduler
- Definition Classes
- Observable
- See also
-
def
repeat(count: Long): Observable[T]
Returns an Observable that repeats the sequence of items emitted by the source Observable at most
counttimes.Returns an Observable that repeats the sequence of items emitted by the source Observable at most
counttimes.
- count
the number of times the source Observable items are repeated, a count of 0 will yield an empty sequence
- returns
an Observable that repeats the sequence of items emitted by the source Observable at most
counttimes
- Definition Classes
- Observable
- Exceptions thrown
java.lang.IllegalArgumentExceptionifcountis less than zero- See also
-
def
repeat(scheduler: Scheduler): Observable[T]
Returns an Observable that repeats the sequence of items emitted by the source Observable indefinitely, on a particular Scheduler.
Returns an Observable that repeats the sequence of items emitted by the source Observable indefinitely, on a particular Scheduler.
- scheduler
the Scheduler to emit the items on
- returns
an Observable that emits the items emitted by the source Observable repeatedly and in sequence
- Definition Classes
- Observable
- See also
-
def
repeat: Observable[T]
Returns an Observable that repeats the sequence of items emitted by the source Observable indefinitely.
Returns an Observable that repeats the sequence of items emitted by the source Observable indefinitely.
- returns
an Observable that emits the items emitted by the source Observable repeatedly and in sequence
- Definition Classes
- Observable
- See also
-
def
repeatWhen(notificationHandler: (Observable[Unit]) ⇒ Observable[Any]): Observable[T]
Returns an Observable that emits the same values as the source Observable with the exception of an
onCompleted.Returns an Observable that emits the same values as the source Observable with the exception of an
onCompleted. AnonCompletednotification from the source will result in the emission of ascala.Unitto the Observable provided as an argument to thenotificationHandlerfunction. If the Observable returnedonCompletesoronErrorsthenrepeatWhenwill callonCompletedoronErroron the child subscription. Otherwise, this Observable will resubscribe to the source observable.
- notificationHandler
receives an Observable of a Unit with which a user can complete or error, aborting the repeat.
- returns
the source Observable modified with repeat logic
- Definition Classes
- Observable
This repeats 3 times, each time incrementing the number of seconds it waits.
Observable[String]({ subscriber => println("subscribing") subscriber.onCompleted() }).repeatWhen({ unitObservable => unitObservable.zipWith(Observable.from(1 to 3))((u, i) => i).flatMap(i => { println("delay repeat by " + i + " second(s)") Observable.timer(Duration(i, TimeUnit.SECONDS)) }) }).toBlocking.foreach(s => println(s))
Output is:
subscribing delay repeat by 1 second(s) subscribing delay repeat by 2 second(s) subscribing delay repeat by 3 second(s) subscribing
<dl> <dt>Scheduler:</dt>
- `repeatWhen` operates by default on the `trampoline` [[Scheduler]].
</dl>- Since
0.20
- See also
Example: -
def
repeatWhen(notificationHandler: (Observable[Unit]) ⇒ Observable[Any], scheduler: Scheduler): Observable[T]
Returns an Observable that emits the same values as the source Observable with the exception of an
onCompleted.Returns an Observable that emits the same values as the source Observable with the exception of an
onCompleted. AnonCompletednotification from the source will result in the emission of ascala.Unitto the Observable provided as an argument to thenotificationHandlerfunction. If the Observable returnedonCompletesoronErrorsthenrepeatWhenwill callonCompletedoronErroron the child subscription. Otherwise, this Observable will resubscribe to the source Observable, on a particular Scheduler.
<dl>
<dt>Scheduler:</dt>
- you specify which [[Scheduler]] this operator will use
</dl>- notificationHandler
receives an Observable of a Unit with which a user can complete or error, aborting the repeat.
- scheduler
the Scheduler to emit the items on
- returns
the source Observable modified with repeat logic
- Definition Classes
- Observable
- Since
0.20
- See also
-
def
replay(scheduler: Scheduler): ConnectableObservable[T]
Returns a
ConnectableObservablethat shares a single subscription to the source Observable that will replay all of its items and notifications to any futureObserveron the givenScheduler.Returns a
ConnectableObservablethat shares a single subscription to the source Observable that will replay all of its items and notifications to any futureObserveron the givenScheduler.
- scheduler
the Scheduler on which the Observers will observe the emitted items
- returns
a
ConnectableObservablethat shares a single subscription to the source Observable that will replay all of its items and notifications to any futurebserveron the givenScheduler
- Definition Classes
- Observable
-
def
replay(time: Duration, scheduler: Scheduler): ConnectableObservable[T]
Returns a
ConnectableObservablethat shares a single subscription to the source Observable and replays all items emitted by that Observable within a specified time window.Returns a
ConnectableObservablethat shares a single subscription to the source Observable and replays all items emitted by that Observable within a specified time window.
- time
the duration of the window in which the replayed items must have been emitted
- scheduler
the Scheduler that is the time source for the window
- returns
a
ConnectableObservablethat shares a single subscription to the source Observable and replays the items that were emitted during the window defined bytime
- Definition Classes
- Observable
-
def
replay(time: Duration): ConnectableObservable[T]
Returns a
ConnectableObservablethat shares a single subscription to the source Observable and replays all items emitted by that Observable within a specified time window.Returns a
ConnectableObservablethat shares a single subscription to the source Observable and replays all items emitted by that Observable within a specified time window.
- time
the duration of the window in which the replayed items must have been emitted
- returns
a
ConnectableObservablethat shares a single subscription to the source Observable and replays the items that were emitted during the window defined bytime
- Definition Classes
- Observable
-
def
replay(bufferSize: Int, scheduler: Scheduler): ConnectableObservable[T]
Returns a
ConnectableObservablethat shares a single subscription to the source Observable and replays at mostbufferSizeitems emitted by that Observable.Returns a
ConnectableObservablethat shares a single subscription to the source Observable and replays at mostbufferSizeitems emitted by that Observable.
- bufferSize
the buffer size that limits the number of items that can be replayed
- scheduler
the scheduler on which the Observers will observe the emitted items
- returns
a
ConnectableObservablethat shares a single subscription to the source Observable and replays at mostbufferSizeitems that were emitted by the Observable
- Definition Classes
- Observable
-
def
replay(bufferSize: Int): ConnectableObservable[T]
Returns a
ConnectableObservablethat shares a single subscription to the source Observable that replays at mostbufferSizeitems emitted by that Observable.Returns a
ConnectableObservablethat shares a single subscription to the source Observable that replays at mostbufferSizeitems emitted by that Observable.
- bufferSize
the buffer size that limits the number of items that can be replayed
- returns
a
ConnectableObservablethat shares a single subscription to the source Observable and replays at mostbufferSizeitems emitted by that Observable
- Definition Classes
- Observable
-
def
replay[R](selector: (Observable[T]) ⇒ Observable[R], time: Duration): Observable[R]
Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replaying all items that were emitted within a specified time window.Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replaying all items that were emitted within a specified time window.
- selector
a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the Observable
- time
the duration of the window in which the replayed items must have been emitted
- returns
an Observable that emits items that are the results of invoking the selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replaying all items that were emitted within the window defined bytime
- Definition Classes
- Observable
-
def
replay(bufferSize: Int, time: Duration, scheduler: Scheduler): ConnectableObservable[T]
Returns a
ConnectableObservablethat shares a single subscription to the source Observable and that replays a maximum ofbufferSizeitems that are emitted within a specified time window.Returns a
ConnectableObservablethat shares a single subscription to the source Observable and that replays a maximum ofbufferSizeitems that are emitted within a specified time window.
- bufferSize
the buffer size that limits the number of items that can be replayed
- time
the duration of the window in which the replayed items must have been emitted
- scheduler
the scheduler that is used as a time source for the window
- returns
a
ConnectableObservablethat shares a single subscription to the source Observable and replays at mostbufferSizeitems that were emitted during the window defined bytime
- Definition Classes
- Observable
- Exceptions thrown
java.lang.IllegalArgumentExceptionifbufferSizeis less than zero
-
def
replay(bufferSize: Int, time: Duration): ConnectableObservable[T]
Returns a
ConnectableObservablethat shares a single subscription to the source Observable and replays at mostbufferSizeitems that were emitted during a specified time window.Returns a
ConnectableObservablethat shares a single subscription to the source Observable and replays at mostbufferSizeitems that were emitted during a specified time window.
- bufferSize
the buffer size that limits the number of items that can be replayed
- time
the duration of the window in which the replayed items must have been emitted
- returns
a
ConnectableObservablethat shares a single subscription to the source Observable and replays at mostbufferSizeitems that were emitted during the window defined bytime
- Definition Classes
- Observable
-
def
replay[R](selector: (Observable[T]) ⇒ Observable[R], scheduler: Scheduler): Observable[R]
Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable.Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable.
- selector
a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the Observable
- scheduler
the Scheduler where the replay is observed
- returns
an Observable that emits items that are the results of invoking the selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replaying all items
- Definition Classes
- Observable
-
def
replay[R](selector: (Observable[T]) ⇒ Observable[R], time: Duration, scheduler: Scheduler): Observable[R]
Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replaying all items that were emitted within a specified time window.Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replaying all items that were emitted within a specified time window.
- selector
a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the Observable
- time
the duration of the window in which the replayed items must have been emitted
- returns
an Observable that emits items that are the results of invoking the selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replaying all items that were emitted within the window defined bytime
- Definition Classes
- Observable
-
def
replay[R](selector: (Observable[T]) ⇒ Observable[R], bufferSize: Int, scheduler: Scheduler): Observable[R]
Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replaying a maximum ofbufferSizeitems.Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replaying a maximum ofbufferSizeitems.
- selector
a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the Observable
- bufferSize
the buffer size that limits the number of items the connectable observable can replay
- scheduler
the Scheduler on which the replay is observed
- returns
an Observable that emits items that are the results of invoking the selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replaying no more thanbufferSizenotifications
- Definition Classes
- Observable
-
def
replay[R](selector: (Observable[T]) ⇒ Observable[R], bufferSize: Int, time: Duration, scheduler: Scheduler): Observable[R]
Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replaying no more thanbufferSizeitems that were emitted within a specified time window.Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replaying no more thanbufferSizeitems that were emitted within a specified time window.
- selector
a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the Observable
- bufferSize
the buffer size that limits the number of items the connectable observable can replay
- time
the duration of the window in which the replayed items must have been emitted
- scheduler
the Scheduler that is the time source for the window
- returns
an Observable that emits items that are the results of invoking the selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, and replays no more thanbufferSizeitems that were emitted within the window defined bytime
- Definition Classes
- Observable
- Exceptions thrown
java.lang.IllegalArgumentExceptionifbufferSizeis less than zero
-
def
replay[R](selector: (Observable[T]) ⇒ Observable[R], bufferSize: Int, time: Duration): Observable[R]
Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replaying no more thanbufferSizeitems that were emitted within a specified time window.Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replaying no more thanbufferSizeitems that were emitted within a specified time window.
- selector
a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the Observable
- bufferSize
the buffer size that limits the number of items the connectable observable can replay
- time
the duration of the window in which the replayed items must have been emitted
- returns
an Observable that emits items that are the results of invoking the selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, and replays no more thanbufferSizeitems that were emitted within the window defined bytime
- Definition Classes
- Observable
-
def
replay[R](selector: (Observable[T]) ⇒ Observable[R], bufferSize: Int): Observable[R]
Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replayingbufferSizenotifications.Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable, replayingbufferSizenotifications.
- selector
the selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the Observable
- bufferSize
the buffer size that limits the number of items the connectable observable can replay
- returns
an Observable that emits items that are the results of invoking the selector on items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable replaying no more thanbufferSizeitems
- Definition Classes
- Observable
-
def
replay[R](selector: (Observable[T]) ⇒ Observable[R]): Observable[R]
Returns an Observable that emits items that are the results of invoking a specified selector on the items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable.Returns an Observable that emits items that are the results of invoking a specified selector on the items emitted by a
ConnectableObservablethat shares a single subscription to the source Observable.
- selector
the selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the Observable
- returns
an Observable that emits items that are the results of invoking the selector on a
ConnectableObservablethat shares a single subscription to the source Observable
- Definition Classes
- Observable
-
def
replay: ConnectableObservable[T]
Returns a rx.lang.scala.observables.ConnectableObservable that shares a single subscription to the underlying Observable that will replay all of its items and notifications to any future rx.lang.scala.Observer.
Returns a rx.lang.scala.observables.ConnectableObservable that shares a single subscription to the underlying Observable that will replay all of its items and notifications to any future rx.lang.scala.Observer.
- returns
a rx.lang.scala.observables.ConnectableObservable such that when the
connectfunction is called, the rx.lang.scala.observables.ConnectableObservable starts to emit items to its rx.lang.scala.Observers
- Definition Classes
- Observable
-
def
retry(predicate: (Int, Throwable) ⇒ Boolean): Observable[T]
Returns an Observable that mirrors the source Observable, resubscribing to it if it calls
onErrorand the predicate returns true for that specific exception and retry count.Returns an Observable that mirrors the source Observable, resubscribing to it if it calls
onErrorand the predicate returns true for that specific exception and retry count.
- predicate
the predicate that determines if a resubscription may happen in case of a specific exception and retry count
- returns
the source Observable modified with retry logic
- Definition Classes
- Observable
-
def
retry: Observable[T]
Retry subscription to origin Observable whenever onError is called (infinite retry count).
Retry subscription to origin Observable whenever onError is called (infinite retry count).

If rx.lang.scala.Observer.onError is invoked the source Observable will be re-subscribed to.
Any rx.lang.scala.Observer.onNext calls received on each attempt will be emitted and concatenated together.
For example, if an Observable fails on first time but emits [1, 2] then succeeds the second time and emits [1, 2, 3, 4, 5] then the complete output would be [1, 2, 1, 2, 3, 4, 5, onCompleted].
- returns
Observable with retry logic.
- Definition Classes
- Observable
-
def
retry(retryCount: Long): Observable[T]
Retry subscription to origin Observable upto given retry count.
Retry subscription to origin Observable upto given retry count.

If rx.lang.scala.Observer.onError is invoked the source Observable will be re-subscribed to as many times as defined by retryCount.
Any rx.lang.scala.Observer.onNext calls received on each attempt will be emitted and concatenated together.
For example, if an Observable fails on first time but emits [1, 2] then succeeds the second time and emits [1, 2, 3, 4, 5] then the complete output would be [1, 2, 1, 2, 3, 4, 5, onCompleted].
- retryCount
Number of retry attempts before failing.
- returns
Observable with retry logic.
- Definition Classes
- Observable
-
def
retryWhen(notificationHandler: (Observable[Throwable]) ⇒ Observable[Any], scheduler: Scheduler): Observable[T]
Returns an Observable that emits the same values as the source observable with the exception of an
onError.Returns an Observable that emits the same values as the source observable with the exception of an
onError. An onError will emit aThrowableto the Observable provided as an argument to thenotificationHandlerfunction. If the Observable returnedonCompletesoronErrorsthen retry will callonCompletedoronErroron the child subscription. Otherwise, this observable will resubscribe to the source observable, on a particular Scheduler.
<dl> <dt>Scheduler:</dt>
- you specify which [[Scheduler]] this operator will use
</dl>- notificationHandler
receives an Observable of a Throwable with which a user can complete or error, aborting the retry
- scheduler
the Scheduler on which to subscribe to the source Observable
- returns
the source Observable modified with retry logic
- Definition Classes
- Observable
- Since
0.20
- See also
RxScalaDemo.retryWhenDifferentExceptionsExample for a more intricate example
-
def
retryWhen(notificationHandler: (Observable[Throwable]) ⇒ Observable[Any]): Observable[T]
Returns an Observable that emits the same values as the source observable with the exception of an
onError.Returns an Observable that emits the same values as the source observable with the exception of an
onError. AnonErrornotification from the source will result in the emission of aThrowableto the Observable provided as an argument to thenotificationHandlerfunction. If the Observable returnedonCompletesoronErrorsthenretrywill callonCompletedoronErroron the child subscription. Otherwise, this Observable will resubscribe to the source Observable.
Example:
This retries 3 times, each time incrementing the number of seconds it waits.
- notificationHandler
receives an Observable of a Throwable with which a user can complete or error, aborting the retry
- returns
the source Observable modified with retry logic
- Definition Classes
- Observable
This retries 3 times, each time incrementing the number of seconds it waits.
Observable[String]({ subscriber => println("subscribing") subscriber.onError(new RuntimeException("always fails")) }).retryWhen({ throwableObservable => throwableObservable.zipWith(Observable.from(1 to 3))((t, i) => i).flatMap(i => { println("delay retry by " + i + " second(s)") Observable.timer(Duration(i, TimeUnit.SECONDS)) }) }).toBlocking.foreach(s => println(s))
Output is:
subscribing delay retry by 1 second(s) subscribing delay retry by 2 second(s) subscribing delay retry by 3 second(s) subscribing
<dl> <dt>Scheduler:</dt>
- `retryWhen` operates by default on the `trampoline` [[Scheduler]].
</dl>- Since
0.20
- See also
RxScalaDemo.retryWhenDifferentExceptionsExample for a more intricate example
Example: -
def
sample(sampler: Observable[Any]): Observable[T]
Return an Observable that emits the results of sampling the items emitted by the source Observable whenever the specified sampler Observable emits an item or completes.
Return an Observable that emits the results of sampling the items emitted by the source Observable whenever the specified sampler Observable emits an item or completes.
- sampler
the Observable to use for sampling the source Observable
- returns
an Observable that emits the results of sampling the items emitted by this Observable whenever the sampler Observable emits an item or completes
- Definition Classes
- Observable
-
def
sample(duration: Duration, scheduler: Scheduler): Observable[T]
Returns an Observable that emits the results of sampling the items emitted by the source Observable at a specified time interval.
Returns an Observable that emits the results of sampling the items emitted by the source Observable at a specified time interval.
- duration
the sampling rate
- scheduler
the rx.lang.scala.Scheduler to use when sampling
- returns
an Observable that emits the results of sampling the items emitted by the source Observable at the specified time interval
- Definition Classes
- Observable
-
def
sample(duration: Duration): Observable[T]
Returns an Observable that emits the results of sampling the items emitted by the source Observable at a specified time interval.
Returns an Observable that emits the results of sampling the items emitted by the source Observable at a specified time interval.
- duration
the sampling rate
- returns
an Observable that emits the results of sampling the items emitted by the source Observable at the specified time interval
- Definition Classes
- Observable
-
def
scan[U >: T](accumulator: (U, U) ⇒ U): Observable[U]
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, then feeds the result of that function along with the second item emitted by an Observable into the same function, and so on until all items have been emitted by the source Observable, emitting the result of each of these iterations.
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, then feeds the result of that function along with the second item emitted by an Observable into the same function, and so on until all items have been emitted by the source Observable, emitting the result of each of these iterations.

- accumulator
an accumulator function to be invoked on each item emitted by the source Observable, whose result will be emitted to rx.lang.scala.Observers via onNext and used in the next accumulator call.
- returns
an Observable that emits the results of each call to the accumulator function
- Definition Classes
- Observable
-
def
scan[R](initialValue: R)(accumulator: (R, T) ⇒ R): Observable[R]
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, then feeds the result of that function along with the second item emitted by an Observable into the same function, and so on until all items have been emitted by the source Observable, emitting the result of each of these iterations.
Returns an Observable that applies a function of your choosing to the first item emitted by a source Observable, then feeds the result of that function along with the second item emitted by an Observable into the same function, and so on until all items have been emitted by the source Observable, emitting the result of each of these iterations.

This sort of function is sometimes called an accumulator.
Note that when you pass a seed to
scan()the resulting Observable will emit that seed as its first emitted item.- initialValue
the initial (seed) accumulator value
- accumulator
an accumulator function to be invoked on each item emitted by the source Observable, whose result will be emitted to rx.lang.scala.Observers via onNext and used in the next accumulator call.
- returns
an Observable that emits the results of each call to the accumulator function
- Definition Classes
- Observable
-
def
sequenceEqual[U >: T](that: Observable[U]): Observable[Boolean]
Returns an Observable that emits a Boolean value that indicates whether
thisandthatObservable sequences are the same by comparing the items emitted by each Observable pairwise.Returns an Observable that emits a Boolean value that indicates whether
thisandthatObservable sequences are the same by comparing the items emitted by each Observable pairwise.
Note: this method uses
==to compare elements. It's a bit different from RxJava which usesObject.equals.- that
the Observable to compare
- returns
an Observable that emits a
Booleanvalue that indicates whether the two sequences are the same
- Definition Classes
- Observable
-
def
sequenceEqualWith[U >: T](that: Observable[U])(equality: (U, U) ⇒ Boolean): Observable[Boolean]
Returns an Observable that emits a Boolean value that indicates whether
thisandthatObservable sequences are the same by comparing the items emitted by each Observable pairwise based on the results of a specifiedequalityfunction.Returns an Observable that emits a Boolean value that indicates whether
thisandthatObservable sequences are the same by comparing the items emitted by each Observable pairwise based on the results of a specifiedequalityfunction.
- that
the Observable to compare
- equality
a function used to compare items emitted by each Observable
- returns
an Observable that emits a
Booleanvalue that indicates whether the two sequences are the same based on theequalityfunction.
- Definition Classes
- Observable
-
def
serialize: Observable[T]
Wraps this Observable in another Observable that ensures that the resulting Observable is chronologically well-behaved.
Wraps this Observable in another Observable that ensures that the resulting Observable is chronologically well-behaved.

A well-behaved Observable does not interleave its invocations of the onNext, onCompleted, and onError methods of its rx.lang.scala.Observers; it invokes
onCompletedoronErroronly once; and it never invokesonNextafter invoking eitheronCompletedoronError. serialize enforces this, and the Observable it returns invokesonNextandonCompletedoronErrorsynchronously.- returns
an Observable that is a chronologically well-behaved version of the source Observable, and that synchronously notifies its rx.lang.scala.Observers
- Definition Classes
- Observable
-
def
share: Observable[T]
Returns a new Observable that multicasts (shares) the original Observable.
Returns a new Observable that multicasts (shares) the original Observable. As long a there is more than 1 Subscriber, this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will unsubscribe from the source Observable.
This is an alias for
publish().refCount()
- returns
a Observable that upon connection causes the source Observable to emit items to its Subscribers
- Definition Classes
- Observable
- Since
0.19
-
def
single: Observable[T]
If the source Observable completes after emitting a single item, return an Observable that emits that item.
If the source Observable completes after emitting a single item, return an Observable that emits that item. If the source Observable emits more than one item or no items, notify of an
IllegalArgumentExceptionorNoSuchElementExceptionrespectively.
- returns
an Observable that emits the single item emitted by the source Observable
- Definition Classes
- Observable
- Exceptions thrown
java.lang.IllegalArgumentExceptionif the source emits more than one itemjava.util.NoSuchElementExceptionif the source emits no items- See also
"MSDN: Observable.singleAsync()"
-
def
singleOption: Observable[Option[T]]
If the source Observable completes after emitting a single item, return an Observable that emits an
Optionwith that item; if the source Observable is empty, return an Observable that emitsNone.If the source Observable completes after emitting a single item, return an Observable that emits an
Optionwith that item; if the source Observable is empty, return an Observable that emitsNone. If the source Observable emits more than one item, throw anIllegalArgumentException.
- returns
an Observable that emits an
Optionwith the single item emitted by the source Observable, orNoneif the source Observable is empty
- Definition Classes
- Observable
- Exceptions thrown
java.lang.IllegalArgumentExceptionif the source Observable emits more than one item
-
def
singleOrElse[U >: T](default: ⇒ U): Observable[U]
If the source Observable completes after emitting a single item, return an Observable that emits that item; if the source Observable is empty, return an Observable that emits a default item.
If the source Observable completes after emitting a single item, return an Observable that emits that item; if the source Observable is empty, return an Observable that emits a default item. If the source Observable emits more than one item, throw an
IllegalArgumentException.
- default
a default value to emit if the source Observable emits no item. This is a by-name parameter, so it is only evaluated if the source Observable doesn't emit anything.
- returns
an Observable that emits the single item emitted by the source Observable, or a default item if the source Observable is empty
- Definition Classes
- Observable
- Exceptions thrown
java.lang.IllegalArgumentExceptionif the source Observable emits more than one item
-
def
size: Observable[Int]
Returns an Observable that counts the total number of elements in the source Observable.
Returns an Observable that counts the total number of elements in the source Observable.
- returns
an Observable emitting the number of counted elements of the source Observable as its single item.
- Definition Classes
- Observable
-
def
sliding(timespan: Duration, timeshift: Duration, count: Int, scheduler: Scheduler): Observable[Observable[T]]
Returns an Observable that emits windows of items it collects from the source Observable.
Returns an Observable that emits windows of items it collects from the source Observable. The resulting Observable starts a new window periodically, as determined by the
timeshiftargument or a maximum size as specified by thecountargument (whichever is reached first). It emits each window after a fixed timespan, specified by thetimespanargument. When the source Observable completes or Observable completes or encounters an error, the resulting Observable emits the current window and propagates the notification from the source Observable.
Backpressure Support:
This operator does not support backpressure as it uses time to control data flow.
Scheduler:
you specify which
Schedulerthis operator will use- timespan
the period of time each window collects items before it should be emitted
- timeshift
the period of time after which a new window will be created
- count
the maximum size of each window before it should be emitted
- scheduler
the
Schedulerto use when determining the end and start of a window- returns
an Observable that emits new windows periodically as a fixed timespan elapses
- Definition Classes
- Observable
- See also
-
def
sliding(timespan: Duration, timeshift: Duration, scheduler: Scheduler): Observable[Observable[T]]
Creates an Observable which produces windows of collected values.
Creates an Observable which produces windows of collected values. This Observable starts a new window periodically, which is determined by the
timeshiftargument. Each window is emitted after a fixed timespan specified by thetimespanargument. When the source Observable completes or encounters an error, the current window is emitted and the event is propagated.- timespan
The period of time each window is collecting values before it should be emitted.
- timeshift
The period of time after which a new window will be created.
- scheduler
The rx.lang.scala.Scheduler to use when determining the end and start of a window.
- returns
An rx.lang.scala.Observable which produces new windows periodically, and these are emitted after a fixed timespan has elapsed.
- Definition Classes
- Observable
-
def
sliding(timespan: Duration, timeshift: Duration): Observable[Observable[T]]
Creates an Observable which produces windows of collected values.
Creates an Observable which produces windows of collected values. This Observable starts a new window periodically, which is determined by the
timeshiftargument. Each window is emitted after a fixed timespan specified by thetimespanargument. When the source Observable completes or encounters an error, the current window is emitted and the event is propagated.- timespan
The period of time each window is collecting values before it should be emitted.
- timeshift
The period of time after which a new window will be created.
- returns
An rx.lang.scala.Observable which produces new windows periodically, and these are emitted after a fixed timespan has elapsed.
- Definition Classes
- Observable
-
def
sliding(count: Int, skip: Int): Observable[Observable[T]]
Creates an Observable which produces windows of collected values.
Creates an Observable which produces windows of collected values. This Observable produces windows every
skipvalues, each containingcountelements. When the source Observable completes or encounters an error, the current window is emitted and the event is propagated.- count
The maximum size of each window before it should be emitted.
- skip
How many produced values need to be skipped before starting a new window. Note that when
skipandcountare equal that this is the same operation aswindow(int).- returns
An rx.lang.scala.Observable which produces windows every
skipvalues containing at mostcountproduced values.
- Definition Classes
- Observable
-
def
sliding[Opening](openings: Observable[Opening])(closings: (Opening) ⇒ Observable[Any]): Observable[Observable[T]]
Creates an Observable which produces windows of collected values.
Creates an Observable which produces windows of collected values. Chunks are created when the specified
openingsObservable produces an object. That object is used to construct an Observable to emit windows, feeding it intoclosingsfunction. Windows are emitted when the created Observable produces an object.- openings
The rx.lang.scala.Observable which when it produces an object, will cause another window to be created.
- closings
The function which is used to produce an rx.lang.scala.Observable for every window created. When this rx.lang.scala.Observable produces an object, the associated window is emitted.
- returns
An rx.lang.scala.Observable which produces windows which are created and emitted when the specified rx.lang.scala.Observables publish certain objects.
- Definition Classes
- Observable
-
def
slidingBuffer(timespan: Duration, timeshift: Duration, scheduler: Scheduler): Observable[Seq[T]]
Creates an Observable which produces buffers of collected values.
Creates an Observable which produces buffers of collected values. This Observable starts a new buffer periodically, which is determined by the
timeshiftargument. Each buffer is emitted after a fixed timespan specified by thetimespanargument. When the source Observable completes or encounters an error, the current buffer is emitted and the event is propagated.- timespan
The period of time each buffer is collecting values before it should be emitted.
- timeshift
The period of time after which a new buffer will be created.
- scheduler
The rx.lang.scala.Scheduler to use when determining the end and start of a buffer.
- returns
An rx.lang.scala.Observable which produces new buffers periodically, and these are emitted after a fixed timespan has elapsed.
- Definition Classes
- Observable
-
def
slidingBuffer(timespan: Duration, timeshift: Duration): Observable[Seq[T]]
Creates an Observable which produces buffers of collected values.
Creates an Observable which produces buffers of collected values. This Observable starts a new buffer periodically, which is determined by the
timeshiftargument. Each buffer is emitted after a fixed timespan specified by thetimespanargument. When the source Observable completes or encounters an error, the current buffer is emitted and the event is propagated.- timespan
The period of time each buffer is collecting values before it should be emitted.
- timeshift
The period of time after which a new buffer will be created.
- returns
An rx.lang.scala.Observable which produces new buffers periodically, and these are emitted after a fixed timespan has elapsed.
- Definition Classes
- Observable
-
def
slidingBuffer(count: Int, skip: Int): Observable[Seq[T]]
Creates an Observable which produces buffers of collected values.
Creates an Observable which produces buffers of collected values.
This Observable produces buffers every
skipvalues, each containingcountelements. When the source Observable completes or encounters an error, the current buffer is emitted, and the event is propagated.- count
The maximum size of each buffer before it should be emitted.
- skip
How many produced values need to be skipped before starting a new buffer. Note that when
skipandcountare equals that this is the same operation asbuffer(int).- returns
An rx.lang.scala.Observable which produces buffers every
skipvalues containing at mostcountproduced values.
- Definition Classes
- Observable
-
def
slidingBuffer[Opening](openings: Observable[Opening])(closings: (Opening) ⇒ Observable[Any]): Observable[Seq[T]]
Creates an Observable which produces buffers of collected values.
Creates an Observable which produces buffers of collected values.
This Observable produces buffers. Buffers are created when the specified
openingsObservable produces an object. That object is used to construct an Observable to emit buffers, feeding it intoclosingsfunction. Buffers are emitted when the created Observable produces an object.- openings
The rx.lang.scala.Observable which, when it produces an object, will cause another buffer to be created.
- closings
The function which is used to produce an rx.lang.scala.Observable for every buffer created. When this rx.lang.scala.Observable produces an object, the associated buffer is emitted.
- returns
An rx.lang.scala.Observable which produces buffers which are created and emitted when the specified rx.lang.scala.Observables publish certain objects.
- Definition Classes
- Observable
-
def
subscribe(onNext: (T) ⇒ Unit, onError: (Throwable) ⇒ Unit, onCompleted: () ⇒ Unit): Subscription
Call this method to receive items and notifications from this observable.
Call this method to receive items and notifications from this observable.
Scheduler:
This method does not operate by default on a particular Scheduler.
- onNext
this function will be called whenever the Observable emits an item
- onError
this function will be called if an error occurs
- onCompleted
this function will be called when this Observable has finished emitting items
- returns
a rx.lang.scala.Subscription reference whose
unsubscribemethod can be called to stop receiving items before the Observable has finished sending them
- Definition Classes
- Observable
- See also
-
def
subscribe(onNext: (T) ⇒ Unit, onError: (Throwable) ⇒ Unit): Subscription
Call this method to receive items and notifications from this observable.
Call this method to receive items and notifications from this observable.
Scheduler:
This method does not operate by default on a particular Scheduler.
- onNext
this function will be called whenever the Observable emits an item
- onError
this function will be called if an error occurs
- returns
a rx.lang.scala.Subscription reference whose
unsubscribemethod can be called to stop receiving items before the Observable has finished sending them
- Definition Classes
- Observable
- See also
-
def
subscribe(onNext: (T) ⇒ Unit): Subscription
Call this method to receive items from this observable.
Call this method to receive items from this observable.
Scheduler:
This method does not operate by default on a particular Scheduler.
- onNext
this function will be called whenever the Observable emits an item
- returns
a rx.lang.scala.Subscription reference whose
unsubscribemethod can be called to stop receiving items before the Observable has finished sending them
- Definition Classes
- Observable
- Exceptions thrown
rx.exceptions.OnErrorNotImplementedExceptionif the Observable tries to callonError- See also
-
def
subscribe(subscriber: Subscriber[T]): Subscription
Call this method to subscribe an Subscriber for receiving items and notifications from the Observable.
Call this method to subscribe an Subscriber for receiving items and notifications from the Observable.
A typical implementation of
subscribedoes the following:It stores a reference to the Observer in a collection object, such as a
List[T]object.It returns a reference to the rx.lang.scala.Subscription interface. This enables Subscribers to unsubscribe, that is, to stop receiving items and notifications before the Observable stops sending them, which also invokes the Subscriber's onCompleted method.
An Observable instance is responsible for accepting all subscriptions and notifying all Subscribers. Unless the documentation for a particular Observable implementation indicates otherwise, Subscribers should make no assumptions about the order in which multiple Subscribers will receive their notifications.
Scheduler:
This method does not operate by default on a particular Scheduler.
- subscriber
the Subscriber
- returns
a rx.lang.scala.Subscription reference whose
unsubscribemethod can be called to stop receiving items before the Observable has finished sending them
- Definition Classes
- Observable
- See also
-
def
subscribe(observer: Observer[T]): Subscription
Call this method to subscribe an rx.lang.scala.Observer for receiving items and notifications from the Observable.
Call this method to subscribe an rx.lang.scala.Observer for receiving items and notifications from the Observable.
A typical implementation of
subscribedoes the following:It stores a reference to the Observer in a collection object, such as a
List[T]object.It returns a reference to the rx.lang.scala.Subscription interface. This enables Observers to unsubscribe, that is, to stop receiving items and notifications before the Observable stops sending them, which also invokes the Observer's onCompleted method.
An
Observable[T]instance is responsible for accepting all subscriptions and notifying all Observers. Unless the documentation for a particularObservable[T]implementation indicates otherwise, Observers should make no assumptions about the order in which multiple Observers will receive their notifications.Scheduler:
This method does not operate by default on a particular Scheduler.
- observer
the observer
- returns
a rx.lang.scala.Subscription reference whose
unsubscribemethod can be called to stop receiving items before the Observable has finished sending them
- Definition Classes
- Observable
- See also
-
def
subscribe(): Subscription
Subscribes to an Observable but ignore its emissions and notifications.
Subscribes to an Observable but ignore its emissions and notifications.
Scheduler:
This method does not operate by default on a particular Scheduler.
- returns
a rx.lang.scala.Subscription reference whose
unsubscribemethod can be called to stop receiving items before the Observable has finished sending them
- Definition Classes
- Observable
- Exceptions thrown
rx.exceptions.OnErrorNotImplementedExceptionif the Observable tries to callonError- See also
-
def
subscribeOn(scheduler: Scheduler): Observable[T]
Asynchronously subscribes and unsubscribes Observers on the specified rx.lang.scala.Scheduler.
Asynchronously subscribes and unsubscribes Observers on the specified rx.lang.scala.Scheduler.
- scheduler
the rx.lang.scala.Scheduler to perform subscription and unsubscription actions on
- returns
the source Observable modified so that its subscriptions and unsubscriptions happen on the specified rx.lang.scala.Scheduler
- Definition Classes
- Observable
-
def
sum: Observable[T]
[use case] Returns an Observable that sums up the elements of this Observable.
[use case]Returns an Observable that sums up the elements of this Observable.
This operation is only available if the elements of this Observable are numbers, otherwise you will get a compilation error.
- returns
an Observable emitting the sum of all the elements of the source Observable as its single item.
- Definition Classes
- Observable
Full Signaturedef sum[U >: T](implicit num: Numeric[U]): Observable[U]
-
def
switch[U]: Observable[U]
[use case] Given an Observable that emits Observables, creates a single Observable that emits the items emitted by the most recently published of those Observables.
[use case]Given an Observable that emits Observables, creates a single Observable that emits the items emitted by the most recently published of those Observables.

This operation is only available if
thisis of typeObservable[Observable[U]]for someU, otherwise you'll get a compilation error.- returns
an Observable that emits only the items emitted by the most recently published Observable
- Definition Classes
- Observable
Full Signaturedef switch[U](implicit evidence: <:<[Observable[T], Observable[Observable[U]]]): Observable[U]
-
def
switchIfEmpty[U >: T](alternate: Observable[U]): Observable[U]
EXPERIMENTAL Returns an Observable that emits the items emitted by the source Observable or the items of an alternate Observable if the source Observable is empty.
EXPERIMENTAL Returns an Observable that emits the items emitted by the source Observable or the items of an alternate Observable if the source Observable is empty.
Scheduler:
This method does not operate by default on a particular Scheduler.
- alternate
the alternate Observable to subscribe to if the source does not emit any items
- returns
an Observable that emits the items emitted by the source Observable or the items of an
- Definition Classes
- Observable
- Annotations
- @Experimental()
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number) alternate Observable if the source Observable is empty.
-
def
switchMap[R](f: (T) ⇒ Observable[R]): Observable[R]
Returns a new Observable by applying a function that you supply to each item emitted by the source Observable that returns an Observable, and then emitting the items emitted by the most recently emitted of these Observables.
Returns a new Observable by applying a function that you supply to each item emitted by the source Observable that returns an Observable, and then emitting the items emitted by the most recently emitted of these Observables.
- f
a function that, when applied to an item emitted by the source Observable, returns an Observable
- returns
an Observable that emits the items emitted by the Observable returned from applying a function to the most recently emitted item emitted by the source Observable
- Definition Classes
- Observable
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
tail: Observable[T]
Returns an Observable that emits all items except the first one, or raises an
UnsupportedOperationExceptionif the source Observable is empty.Returns an Observable that emits all items except the first one, or raises an
UnsupportedOperationExceptionif the source Observable is empty.- returns
an Observable that emits all items except the first one, or raises an
UnsupportedOperationExceptionif the source Observable is empty.
- Definition Classes
- Observable
-
def
take(time: Duration, scheduler: Scheduler): Observable[T]
Returns an Observable that emits those items emitted by source Observable before a specified time (on specified Scheduler) runs out
Returns an Observable that emits those items emitted by source Observable before a specified time (on specified Scheduler) runs out
- time
the length of the time window
- scheduler
the Scheduler used for time source
- returns
an Observable that emits those items emitted by the source Observable before the time runs out, according to the specified Scheduler
- Definition Classes
- Observable
-
def
take(time: Duration): Observable[T]
Returns an Observable that emits those items emitted by source Observable before a specified time runs out.
Returns an Observable that emits those items emitted by source Observable before a specified time runs out.
- time
the length of the time window
- returns
an Observable that emits those items emitted by the source Observable before the time runs out
- Definition Classes
- Observable
-
def
take(n: Int): Observable[T]
Returns an Observable that emits only the first
numitems emitted by the source Observable.Returns an Observable that emits only the first
numitems emitted by the source Observable.
This method returns an Observable that will invoke a subscribing rx.lang.scala.Observer's onNext function a maximum of
numtimes before invoking onCompleted.- n
the number of items to take
- returns
an Observable that emits only the first
numitems from the source Observable, or all of the items from the source Observable if that Observable emits fewer thannumitems
- Definition Classes
- Observable
-
def
takeRight(count: Int, time: Duration, scheduler: Scheduler): Observable[T]
Return an Observable that emits at most a specified number of items from the source Observable that were emitted in a specified window of
timebefore the Observable completed, where the timing information is provided by a given Scheduler.Return an Observable that emits at most a specified number of items from the source Observable that were emitted in a specified window of
timebefore the Observable completed, where the timing information is provided by a given Scheduler.
- count
the maximum number of items to emit
- time
the length of the time window
- scheduler
the Scheduler that provides the timestamps for the observed items
- returns
an Observable that emits at most
countitems from the source Observable that were emitted in a specified window of time before the Observable completed, where the timing information is provided by the givenscheduler
- Definition Classes
- Observable
- Exceptions thrown
java.lang.IllegalArgumentExceptionifcountis less than zero
-
def
takeRight(count: Int, time: Duration): Observable[T]
Return an Observable that emits at most a specified number of items from the source Observable that were emitted in a specified window of time before the Observable completed.
Return an Observable that emits at most a specified number of items from the source Observable that were emitted in a specified window of time before the Observable completed.
- count
the maximum number of items to emit
- time
the length of the time window
- returns
an Observable that emits at most
countitems from the source Observable that were emitted in a specified window of time before the Observable completed
- Definition Classes
- Observable
- Exceptions thrown
java.lang.IllegalArgumentExceptionifcountis less than zero
-
def
takeRight(time: Duration, scheduler: Scheduler): Observable[T]
Return an Observable that emits the items from the source Observable that were emitted in a specified window of
timebefore the Observable completed, where the timing information is provided by a specified Scheduler.Return an Observable that emits the items from the source Observable that were emitted in a specified window of
timebefore the Observable completed, where the timing information is provided by a specified Scheduler.
- time
the length of the time window
- scheduler
the Scheduler that provides the timestamps for the Observed items
- returns
an Observable that emits the items from the source Observable that were emitted in the window of time before the Observable completed specified by
time, where the timing information is provided byscheduler
- Definition Classes
- Observable
-
def
takeRight(time: Duration): Observable[T]
Return an Observable that emits the items from the source Observable that were emitted in a specified window of
timebefore the Observable completed.Return an Observable that emits the items from the source Observable that were emitted in a specified window of
timebefore the Observable completed.
- time
the length of the time window
- returns
an Observable that emits the items from the source Observable that were emitted in the window of time before the Observable completed specified by
time
- Definition Classes
- Observable
-
def
takeRight(count: Int): Observable[T]
Returns an Observable that emits only the last
countitems emitted by the source Observable.Returns an Observable that emits only the last
countitems emitted by the source Observable.
- count
the number of items to emit from the end of the sequence emitted by the source Observable
- returns
an Observable that emits only the last
countitems emitted by the source Observable
- Definition Classes
- Observable
-
def
takeUntil(that: Observable[Any]): Observable[T]
Returns an Observable that emits the items from the source Observable only until the
otherObservable emits an item.Returns an Observable that emits the items from the source Observable only until the
otherObservable emits an item.
- that
the Observable whose first emitted item will cause
takeUntilto stop emitting items from the source Observable- returns
an Observable that emits the items of the source Observable until such time as
otheremits its first item
- Definition Classes
- Observable
-
def
takeUntil(stopPredicate: (T) ⇒ Boolean): Observable[T]
EXPERIMENTAL Returns an Observable that emits items emitted by the source Observable, checks the specified predicate for each item, and then completes if the condition is satisfied.
EXPERIMENTAL Returns an Observable that emits items emitted by the source Observable, checks the specified predicate for each item, and then completes if the condition is satisfied.

The difference between this operator and
takeWhile(T => Boolean)is that here, the condition is evaluated after the item is emitted.Scheduler:
This method does not operate by default on a particular Scheduler.
- stopPredicate
a function that evaluates an item emitted by the source Observable and returns a Boolean
- returns
an Observable that first emits items emitted by the source Observable, checks the specified condition after each item, and then completes if the condition is satisfied.
- Definition Classes
- Observable
- Annotations
- @Experimental()
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
- See also
-
def
takeWhile(predicate: (T) ⇒ Boolean): Observable[T]
Returns an Observable that emits items emitted by the source Observable so long as a specified condition is true.
Returns an Observable that emits items emitted by the source Observable so long as a specified condition is true.
- predicate
a function that evaluates an item emitted by the source Observable and returns a Boolean
- returns
an Observable that emits the items from the source Observable so long as each item satisfies the condition defined by
predicate
- Definition Classes
- Observable
-
def
throttleFirst(skipDuration: Duration): Observable[T]
Throttles by skipping value until
skipDurationpasses and then emits the next received value.Throttles by skipping value until
skipDurationpasses and then emits the next received value.This differs from
Observable.throttleLastin that this only tracks passage of time whereasObservable.throttleLastticks at scheduled intervals.
- skipDuration
Time to wait before sending another value after emitting last value.
- returns
Observable which performs the throttle operation.
- Definition Classes
- Observable
-
def
throttleFirst(skipDuration: Duration, scheduler: Scheduler): Observable[T]
Throttles by skipping value until
skipDurationpasses and then emits the next received value.Throttles by skipping value until
skipDurationpasses and then emits the next received value.This differs from
Observable.throttleLastin that this only tracks passage of time whereasObservable.throttleLastticks at scheduled intervals.
- skipDuration
Time to wait before sending another value after emitting last value.
- scheduler
The rx.lang.scala.Scheduler to use internally to manage the timers which handle timeout for each event.
- returns
Observable which performs the throttle operation.
- Definition Classes
- Observable
-
def
throttleLast(intervalDuration: Duration, scheduler: Scheduler): Observable[T]
Throttles by returning the last value of each interval defined by 'intervalDuration'.
Throttles by returning the last value of each interval defined by 'intervalDuration'.
This differs from
Observable.throttleFirstin that this ticks along at a scheduled interval whereasObservable.throttleFirstdoes not tick, it just tracks passage of time.
- intervalDuration
Duration of windows within with the last value will be chosen.
- returns
Observable which performs the throttle operation.
- Definition Classes
- Observable
-
def
throttleLast(intervalDuration: Duration): Observable[T]
Throttles by returning the last value of each interval defined by 'intervalDuration'.
Throttles by returning the last value of each interval defined by 'intervalDuration'.
This differs from
Observable.throttleFirstin that this ticks along at a scheduled interval whereasObservable.throttleFirstdoes not tick, it just tracks passage of time.
- intervalDuration
Duration of windows within with the last value will be chosen.
- returns
Observable which performs the throttle operation.
- Definition Classes
- Observable
-
def
throttleWithTimeout(timeout: Duration, scheduler: Scheduler): Observable[T]
Debounces by dropping all values that are followed by newer values before the timeout value expires.
Debounces by dropping all values that are followed by newer values before the timeout value expires. The timer resets on each
onNextcall.NOTE: If events keep firing faster than the timeout then no data will be emitted.
- timeout
The time each value has to be 'the most recent' of the rx.lang.scala.Observable to ensure that it's not dropped.
- scheduler
The rx.lang.scala.Scheduler to use internally to manage the timers which handle timeout for each event.
- returns
Observable which performs the throttle operation.
- Definition Classes
- Observable
- See also
Observable.debounce
-
def
throttleWithTimeout(timeout: Duration): Observable[T]
Debounces by dropping all values that are followed by newer values before the timeout value expires.
Debounces by dropping all values that are followed by newer values before the timeout value expires. The timer resets on each
onNextcall.NOTE: If events keep firing faster than the timeout then no data will be emitted.

Information on debounce vs throttle:
- timeout
The time each value has to be 'the most recent' of the rx.lang.scala.Observable to ensure that it's not dropped.
- returns
An rx.lang.scala.Observable which filters out values which are too quickly followed up with newer values.
- Definition Classes
- Observable
- See also
Observable.debounce
-
def
timeInterval(scheduler: Scheduler): Observable[(Duration, T)]
Returns an Observable that emits records of the time interval between consecutive items emitted by the source Observable, where this interval is computed on a specified Scheduler.
Returns an Observable that emits records of the time interval between consecutive items emitted by the source Observable, where this interval is computed on a specified Scheduler.
- scheduler
the Scheduler used to compute time intervals
- returns
an Observable that emits time interval information items
- Definition Classes
- Observable
-
def
timeInterval: Observable[(Duration, T)]
Returns an Observable that emits records of the time interval between consecutive items emitted by the source Observable.
Returns an Observable that emits records of the time interval between consecutive items emitted by the source Observable.
- returns
an Observable that emits time interval information items
- Definition Classes
- Observable
-
def
timeout[U >: T](firstTimeoutSelector: () ⇒ Observable[Any], timeoutSelector: (T) ⇒ Observable[Any], other: Observable[U]): Observable[U]
Returns an Observable that mirrors the source Observable, but switches to a fallback Observable if either the first item emitted by the source Observable or any subsequent item don't arrive within time windows defined by other Observables.
Returns an Observable that mirrors the source Observable, but switches to a fallback Observable if either the first item emitted by the source Observable or any subsequent item don't arrive within time windows defined by other Observables.
- firstTimeoutSelector
a function that returns an Observable which determines the timeout window for the first source item
- timeoutSelector
a function that returns an Observable for each item emitted by the source Observable and that determines the timeout window in which the subsequent source item must arrive in order to continue the sequence
- other
the fallback Observable to switch to if the source Observable times out
- returns
an Observable that mirrors the source Observable, but switches to the
otherObservable if either the first item emitted by the source Observable or any subsequent item don't arrive within time windows defined by the timeout selectors
- Definition Classes
- Observable
-
def
timeout(firstTimeoutSelector: () ⇒ Observable[Any], timeoutSelector: (T) ⇒ Observable[Any]): Observable[T]
Returns an Observable that mirrors the source Observable, but emits a TimeoutException if either the first item emitted by the source Observable or any subsequent item don't arrive within time windows defined by other Observables.
Returns an Observable that mirrors the source Observable, but emits a TimeoutException if either the first item emitted by the source Observable or any subsequent item don't arrive within time windows defined by other Observables.
- firstTimeoutSelector
a function that returns an Observable that determines the timeout window for the first source item
- timeoutSelector
a function that returns an Observable for each item emitted by the source Observable and that determines the timeout window in which the subsequent source item must arrive in order to continue the sequence
- returns
an Observable that mirrors the source Observable, but emits a TimeoutException if either the first item or any subsequent item doesn't arrive within the time windows specified by the timeout selectors
- Definition Classes
- Observable
-
def
timeout[U >: T](timeoutSelector: (T) ⇒ Observable[Any], other: Observable[U]): Observable[U]
Returns an Observable that mirrors the source Observable, but that switches to a fallback Observable if an item emitted by the source Observable doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by an Observable that is a function of the previous item.
Returns an Observable that mirrors the source Observable, but that switches to a fallback Observable if an item emitted by the source Observable doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by an Observable that is a function of the previous item.

Note: The arrival of the first source item is never timed out.
- timeoutSelector
a function that returns an observable for each item emitted by the source Observable and that determines the timeout window for the subsequent item
- other
the fallback Observable to switch to if the source Observable times out
- returns
an Observable that mirrors the source Observable, but switches to mirroring a fallback Observable if a item emitted by the source Observable takes longer to arrive than the time window defined by the selector for the previously emitted item
- Definition Classes
- Observable
-
def
timeout(timeoutSelector: (T) ⇒ Observable[Any]): Observable[T]
Returns an Observable that mirrors the source Observable, but emits a TimeoutException if an item emitted by the source Observable doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by an Observable that is a function of the previous item.
Returns an Observable that mirrors the source Observable, but emits a TimeoutException if an item emitted by the source Observable doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by an Observable that is a function of the previous item.

Note: The arrival of the first source item is never timed out.
- timeoutSelector
a function that returns an observable for each item emitted by the source Observable and that determines the timeout window for the subsequent item
- returns
an Observable that mirrors the source Observable, but emits a TimeoutException if a item emitted by the source Observable takes longer to arrive than the time window defined by the selector for the previously emitted item
- Definition Classes
- Observable
-
def
timeout[U >: T](timeout: Duration, other: Observable[U], scheduler: Scheduler): Observable[U]
Applies a timeout policy for each item emitted by the Observable, using the specified scheduler to run timeout timers.
Applies a timeout policy for each item emitted by the Observable, using the specified scheduler to run timeout timers. If the next item isn't observed within the specified timeout duration starting from its predecessor, a specified fallback Observable sequence produces future items and notifications from that point on.
- timeout
maximum duration between items before a timeout occurs
- other
Observable to use as the fallback in case of a timeout
- scheduler
Scheduler to run the timeout timers on
- returns
the source Observable modified so that it will switch to the fallback Observable in case of a timeout
- Definition Classes
- Observable
-
def
timeout(timeout: Duration, scheduler: Scheduler): Observable[T]
Applies a timeout policy for each item emitted by the Observable, using the specified scheduler to run timeout timers.
Applies a timeout policy for each item emitted by the Observable, using the specified scheduler to run timeout timers. If the next item isn't observed within the specified timeout duration starting from its predecessor, the observer is notified of a
TimeoutException.
- timeout
maximum duration between items before a timeout occurs
- scheduler
Scheduler to run the timeout timers on
- returns
the source Observable modified to notify observers of a
TimeoutExceptionin case of a timeout
- Definition Classes
- Observable
-
def
timeout[U >: T](timeout: Duration, other: Observable[U]): Observable[U]
Applies a timeout policy for each item emitted by the Observable, using the specified scheduler to run timeout timers.
Applies a timeout policy for each item emitted by the Observable, using the specified scheduler to run timeout timers. If the next item isn't observed within the specified timeout duration starting from its predecessor, a specified fallback Observable produces future items and notifications from that point on.
- timeout
maximum duration between items before a timeout occurs
- other
fallback Observable to use in case of a timeout
- returns
the source Observable modified to switch to the fallback Observable in case of a timeout
- Definition Classes
- Observable
-
def
timeout(timeout: Duration): Observable[T]
Applies a timeout policy for each item emitted by the Observable, using the specified scheduler to run timeout timers.
Applies a timeout policy for each item emitted by the Observable, using the specified scheduler to run timeout timers. If the next item isn't observed within the specified timeout duration starting from its predecessor, observers are notified of a
TimeoutException.
- timeout
maximum duration between items before a timeout occurs
- returns
the source Observable modified to notify observers of a
TimeoutExceptionin case of a timeout
- Definition Classes
- Observable
-
def
timestamp(scheduler: Scheduler): Observable[(Long, T)]
Wraps each item emitted by a source Observable in a timestamped tuple with timestamps provided by the given Scheduler.
Wraps each item emitted by a source Observable in a timestamped tuple with timestamps provided by the given Scheduler.
- scheduler
rx.lang.scala.Scheduler to use as a time source.
- returns
an Observable that emits timestamped items from the source Observable with timestamps provided by the given Scheduler
- Definition Classes
- Observable
-
def
timestamp: Observable[(Long, T)]
Wraps each item emitted by a source Observable in a timestamped tuple.
Wraps each item emitted by a source Observable in a timestamped tuple.
- returns
an Observable that emits timestamped items from the source Observable
- Definition Classes
- Observable
-
def
to[Col[_]](implicit cbf: CanBuildFrom[Nothing, T, Col[T]]): Observable[Col[T]]
Returns an Observable that emits a single item, a collection composed of all the items emitted by the source Observable.
Returns an Observable that emits a single item, a collection composed of all the items emitted by the source Observable.
Be careful not to use this operator on Observables that emit infinite or very large numbers of items, as you do not have the option to unsubscribe.
- Col
the collection type to build.
- returns
an Observable that emits a single item, a collection containing all of the items emitted by the source Observable.
- Definition Classes
- Observable
-
def
to[M[_, _], K, V](keySelector: (T) ⇒ K, valueSelector: (T) ⇒ V)(implicit cbf: CanBuildFrom[Nothing, (K, V), M[K, V]]): Observable[M[K, V]]
Return an Observable that emits a single
Mapcontaining values corresponding to items emitted by the source Observable, mapped by the keys returned by a specifiedkeySelectorfunction.Return an Observable that emits a single
Mapcontaining values corresponding to items emitted by the source Observable, mapped by the keys returned by a specifiedkeySelectorfunction.
- keySelector
the function that extracts the key from a source item to be used in the
Map- valueSelector
the function that extracts the value from a source item to be used in the
Map- cbf
CanBuildFromto build theMap- returns
an Observable that emits a single item: a
Mapcontaining the mapped items from the source Observable
- Definition Classes
- Observable
-
def
toArray[U >: T](implicit arg0: ClassTag[U]): Observable[Array[U]]
Returns an Observable that emits a single item, an
Arraycomposed of all the items emitted by the source Observable.Returns an Observable that emits a single item, an
Arraycomposed of all the items emitted by the source Observable.Be careful not to use this operator on Observables that emit infinite or very large numbers of items, as you do not have the option to unsubscribe.
- returns
an Observable that emits a single item, an
Arraycontaining all of the items emitted by the source Observable.
- Definition Classes
- Observable
-
def
toBlocking: BlockingObservable[T]
Converts an Observable into a BlockingObservable (an Observable with blocking operators).
Converts an Observable into a BlockingObservable (an Observable with blocking operators).
- returns
a BlockingObservable version of this Observable
- Definition Classes
- Observable
- Since
0.19
- See also
-
def
toBuffer[U >: T]: Observable[Buffer[U]]
Returns an Observable that emits a single item, a
Buffercomposed of all the items emitted by the source Observable.Returns an Observable that emits a single item, a
Buffercomposed of all the items emitted by the source Observable.Be careful not to use this operator on Observables that emit infinite or very large numbers of items, as you do not have the option to unsubscribe.
- returns
an Observable that emits a single item, a
Buffercontaining all of the items emitted by the source Observable.
- Definition Classes
- Observable
-
def
toIndexedSeq: Observable[IndexedSeq[T]]
Returns an Observable that emits a single item, an
IndexedSeqcomposed of all the items emitted by the source Observable.Returns an Observable that emits a single item, an
IndexedSeqcomposed of all the items emitted by the source Observable.Be careful not to use this operator on Observables that emit infinite or very large numbers of items, as you do not have the option to unsubscribe.
- returns
an Observable that emits a single item, an
IndexedSeqcontaining all of the items emitted by the source Observable.
- Definition Classes
- Observable
-
def
toIterable: Observable[Iterable[T]]
Returns an Observable that emits a single item, an
Iterablecomposed of all the items emitted by the source Observable.Returns an Observable that emits a single item, an
Iterablecomposed of all the items emitted by the source Observable.Be careful not to use this operator on Observables that emit infinite or very large numbers of items, as you do not have the option to unsubscribe.
- returns
an Observable that emits a single item, an
Iterablecontaining all of the items emitted by the source Observable.
- Definition Classes
- Observable
-
def
toIterator: Observable[Iterator[T]]
Returns an Observable that emits a single item, an
Iteratorcomposed of all the items emitted by the source Observable.Returns an Observable that emits a single item, an
Iteratorcomposed of all the items emitted by the source Observable.Be careful not to use this operator on Observables that emit infinite or very large numbers of items, as you do not have the option to unsubscribe.
- returns
an Observable that emits a single item, an
Iteratorcontaining all of the items emitted by the source Observable.
- Definition Classes
- Observable
-
def
toList: Observable[List[T]]
Returns an Observable that emits a single item, a
Listcomposed of all the items emitted by the source Observable.Returns an Observable that emits a single item, a
Listcomposed of all the items emitted by the source Observable.Be careful not to use this operator on Observables that emit infinite or very large numbers of items, as you do not have the option to unsubscribe.
- returns
an Observable that emits a single item, a
Listcontaining all of the items emitted by the source Observable.
- Definition Classes
- Observable
-
def
toMap[K, V](keySelector: (T) ⇒ K, valueSelector: (T) ⇒ V): Observable[Map[K, V]]
Return an Observable that emits a single
Mapcontaining values corresponding to items emitted by the source Observable, mapped by the keys returned by a specifiedkeySelectorfunction.Return an Observable that emits a single
Mapcontaining values corresponding to items emitted by the source Observable, mapped by the keys returned by a specifiedkeySelectorfunction.
If more than one source item maps to the same key, the
Mapwill contain a single entry that corresponds to the latest of those items.- keySelector
the function that extracts the key from a source item to be used in the
Map- valueSelector
the function that extracts the value from a source item to be used in the
Map- returns
an Observable that emits a single item: an
Mapcontaining the mapped items from the source Observable
- Definition Classes
- Observable
-
def
toMap[K](keySelector: (T) ⇒ K): Observable[Map[K, T]]
Return an Observable that emits a single
Mapcontaining all items emitted by the source Observable, mapped by the keys returned by a specifiedkeySelectorfunction.Return an Observable that emits a single
Mapcontaining all items emitted by the source Observable, mapped by the keys returned by a specifiedkeySelectorfunction.
If more than one source item maps to the same key, the
Mapwill contain the latest of those items.- keySelector
the function that extracts the key from a source item to be used in the
Map- returns
an Observable that emits a single item: an
Mapcontaining the mapped items from the source Observable
- Definition Classes
- Observable
-
def
toMap[K, V](implicit ev: <:<[Observable[T], Observable[(K, V)]]): Observable[Map[K, V]]
Return an Observable that emits a single
Mapcontaining all pairs emitted by the source Observable.Return an Observable that emits a single
Mapcontaining all pairs emitted by the source Observable. This method is unavailable unless the elements are members of(K, V). Each(K, V)becomes a key-value pair in the map. If more than one pairs have the same key, theMapwill contain the latest of those items.- returns
an Observable that emits a single item: an
Mapcontaining all pairs from the source Observable
- Definition Classes
- Observable
-
def
toMultiMap[K, V, M <: MultiMap[K, V]](keySelector: (T) ⇒ K, valueSelector: (T) ⇒ V, multiMapFactory: ⇒ M): Observable[M]
Returns an Observable that emits a single
mutable.MultiMap, returned by a specifiedmultiMapFactoryfunction, that contains values extracted by a specifiedvalueSelectorfunction from items emitted by the source Observable, and keyed by thekeySelectorfunction.Returns an Observable that emits a single
mutable.MultiMap, returned by a specifiedmultiMapFactoryfunction, that contains values extracted by a specifiedvalueSelectorfunction from items emitted by the source Observable, and keyed by thekeySelectorfunction. The values having the same key will be put into aSet.
- keySelector
the function that extracts a key from the source items to be used as the key in the
mutable.MultiMap- valueSelector
the function that extracts a value from the source items to be used as the value in the
mutable.MultiMap- multiMapFactory
a
mutable.MultiMapinstance to be used. Note: tis is a by-name parameter.- returns
an Observable that emits a single item: a
mutable.MultiMapthat contains keys and values mapped from the source Observable.
- Definition Classes
- Observable
-
def
toMultiMap[K, V](keySelector: (T) ⇒ K, valueSelector: (T) ⇒ V): Observable[MultiMap[K, V]]
Returns an Observable that emits a single
mutable.MultiMapthat contains values extracted by a specifiedvalueSelectorfunction from items emitted by the source Observable, keyed by a specifiedkeySelectorfunction.Returns an Observable that emits a single
mutable.MultiMapthat contains values extracted by a specifiedvalueSelectorfunction from items emitted by the source Observable, keyed by a specifiedkeySelectorfunction. The values having the same key will be put into aSet.
- keySelector
the function that extracts a key from the source items to be used as key in the
mutable.MultiMap- valueSelector
the function that extracts a value from the source items to be used as value in the
mutable.MultiMap- returns
an Observable that emits a single item: a
mutable.MultiMapthat contains keys and values mapped from the source Observable
- Definition Classes
- Observable
-
def
toMultiMap[K, V >: T](keySelector: (T) ⇒ K): Observable[MultiMap[K, V]]
Returns an Observable that emits a single
mutable.MultiMapthat contains items emitted by the source Observable keyed by a specifiedkeySelectorfunction.Returns an Observable that emits a single
mutable.MultiMapthat contains items emitted by the source Observable keyed by a specifiedkeySelectorfunction. The items having the same key will be put into aSet.
- keySelector
the function that extracts the key from the source items to be used as key in the
mutable.MultiMap- returns
an Observable that emits a single item: a
mutable.MultiMapthat contains items emitted by the source Observable keyed by a specifiedkeySelectorfunction.
- Definition Classes
- Observable
-
def
toSeq: Observable[Seq[T]]
Returns an Observable that emits a single item, a list composed of all the items emitted by the source Observable.
Returns an Observable that emits a single item, a list composed of all the items emitted by the source Observable.

Normally, an Observable that returns multiple items will do so by invoking its rx.lang.scala.Observer's onNext method for each such item. You can change this behavior, instructing the Observable to compose a list of all of these items and then to invoke the Observer's
onNextfunction once, passing it the entire list, by calling the Observable'stoListmethod prior to calling itsObservable.subscribemethod.Be careful not to use this operator on Observables that emit infinite or very large numbers of items, as you do not have the option to unsubscribe.
- returns
an Observable that emits a single item: a List containing all of the items emitted by the source Observable.
- Definition Classes
- Observable
-
def
toSerialized: SerializedSubject[T]
Wraps a Subject so that it is safe to call its various
onmethods from different threads.Wraps a Subject so that it is safe to call its various
onmethods from different threads.When you use an ordinary Subject as a Subscriber, you must take care not to call its Subscriber.onNext method (or its other
onmethods) from multiple threads, as this could lead to non-serialized calls, which violates the Observable contract and creates an ambiguity in the resulting Subject.To protect a Subject from this danger, you can convert it into a SerializedSubject with code like the following:
mySafeSubject = myUnsafeSubject.toSerialized
- returns
SerializedSubject wrapping the current Subject
-
def
toSet[U >: T]: Observable[Set[U]]
Returns an Observable that emits a single item, a
Setcomposed of all the items emitted by the source Observable.Returns an Observable that emits a single item, a
Setcomposed of all the items emitted by the source Observable.Be careful not to use this operator on Observables that emit infinite or very large numbers of items, as you do not have the option to unsubscribe.
- returns
an Observable that emits a single item, a
Setcontaining all of the items emitted by the source Observable.
- Definition Classes
- Observable
-
def
toStream: Observable[Stream[T]]
Returns an Observable that emits a single item, a
Streamcomposed of all the items emitted by the source Observable.Returns an Observable that emits a single item, a
Streamcomposed of all the items emitted by the source Observable.Be careful not to use this operator on Observables that emit infinite or very large numbers of items, as you do not have the option to unsubscribe.
- returns
an Observable that emits a single item, a
Streamcontaining all of the items emitted by the source Observable.
- Definition Classes
- Observable
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
toTraversable: Observable[Traversable[T]]
Returns an Observable that emits a single item, a
Traversablecomposed of all the items emitted by the source Observable.Returns an Observable that emits a single item, a
Traversablecomposed of all the items emitted by the source Observable.Be careful not to use this operator on Observables that emit infinite or very large numbers of items, as you do not have the option to unsubscribe.
- returns
an Observable that emits a single item, a
Traversablecontaining all of the items emitted by the source Observable.
- Definition Classes
- Observable
-
def
toVector: Observable[Vector[T]]
Returns an Observable that emits a single item, a
Vectorcomposed of all the items emitted by the source Observable.Returns an Observable that emits a single item, a
Vectorcomposed of all the items emitted by the source Observable.Be careful not to use this operator on Observables that emit infinite or very large numbers of items, as you do not have the option to unsubscribe.
- returns
an Observable that emits a single item, a
Vectorcontaining all of the items emitted by the source Observable.
- Definition Classes
- Observable
-
def
tumbling(timespan: Duration, count: Int, scheduler: Scheduler): Observable[Observable[T]]
Creates an Observable which produces windows of collected values.
Creates an Observable which produces windows of collected values. This Observable produces connected non-overlapping windows, each of a fixed duration specified by the
timespanargument or a maximum size specified by thecountargument (which ever is reached first). When the source Observable completes or encounters an error, the current window is emitted and the event is propagated.- timespan
The period of time each window is collecting values before it should be emitted, and replaced with a new window.
- count
The maximum size of each window before it should be emitted.
- scheduler
The rx.lang.scala.Scheduler to use when determining the end and start of a window.
- returns
An rx.lang.scala.Observable which produces connected non-overlapping windows which are emitted after a fixed duration or when the window has reached maximum capacity (which ever occurs first).
- Definition Classes
- Observable
-
def
tumbling(timespan: Duration, count: Int): Observable[Observable[T]]
Creates an Observable which produces windows of collected values.
Creates an Observable which produces windows of collected values. This Observable produces connected non-overlapping windows, each of a fixed duration specified by the
timespanargument or a maximum size specified by thecountargument (which ever is reached first). When the source Observable completes or encounters an error, the current window is emitted and the event is propagated.- timespan
The period of time each window is collecting values before it should be emitted, and replaced with a new window.
- count
The maximum size of each window before it should be emitted.
- returns
An rx.lang.scala.Observable which produces connected non-overlapping windows which are emitted after a fixed duration or when the window has reached maximum capacity (which ever occurs first).
- Definition Classes
- Observable
-
def
tumbling(timespan: Duration, scheduler: Scheduler): Observable[Observable[T]]
Creates an Observable which produces windows of collected values.
Creates an Observable which produces windows of collected values. This Observable produces connected non-overlapping windows, each of a fixed duration specified by the
timespanargument. When the source Observable completes or encounters an error, the current window is emitted and the event is propagated.- timespan
The period of time each window is collecting values before it should be emitted, and replaced with a new window.
- scheduler
The rx.lang.scala.Scheduler to use when determining the end and start of a window.
- returns
An rx.lang.scala.Observable which produces connected non-overlapping windows with a fixed duration.
- Definition Classes
- Observable
-
def
tumbling(timespan: Duration): Observable[Observable[T]]
Creates an Observable which produces windows of collected values.
Creates an Observable which produces windows of collected values. This Observable produces connected non-overlapping windows, each of a fixed duration specified by the
timespanargument. When the source Observable completes or encounters an error, the current window is emitted and the event is propagated.- timespan
The period of time each window is collecting values before it should be emitted, and replaced with a new window.
- returns
An rx.lang.scala.Observable which produces connected non-overlapping windows with a fixed duration.
- Definition Classes
- Observable
-
def
tumbling(count: Int): Observable[Observable[T]]
Creates an Observable which produces windows of collected values.
Creates an Observable which produces windows of collected values. This Observable produces connected non-overlapping windows, each containing
countelements. When the source Observable completes or encounters an error, the current window is emitted, and the event is propagated.- count
The maximum size of each window before it should be emitted.
- returns
An rx.lang.scala.Observable which produces connected non-overlapping windows containing at most
countproduced values.
- Definition Classes
- Observable
-
def
tumbling(boundary: ⇒ Observable[Any]): Observable[Observable[T]]
Creates an Observable which produces windows of collected values.
Creates an Observable which produces windows of collected values. This Observable produces connected non-overlapping windows. The boundary of each window is determined by the items emitted from a specified boundary-governing Observable.
- boundary
an Observable whose emitted items close and open windows. Note: This is a by-name parameter, so it is only evaluated when someone subscribes to the returned Observable.
- returns
An Observable which produces connected non-overlapping windows. The boundary of each window is determined by the items emitted from a specified boundary-governing Observable.
- Definition Classes
- Observable
-
def
tumblingBuffer(boundary: Observable[Any], initialCapacity: Int): Observable[Seq[T]]
Returns an Observable that emits non-overlapping buffered items from the source Observable each time the specified boundary Observable emits an item.
Returns an Observable that emits non-overlapping buffered items from the source Observable each time the specified boundary Observable emits an item.

Completion of either the source or the boundary Observable causes the returned Observable to emit the latest buffer and complete.
- boundary
the boundary Observable
- initialCapacity
the initial capacity of each buffer chunk
- returns
an Observable that emits buffered items from the source Observable when the boundary Observable emits an item
- Definition Classes
- Observable
-
def
tumblingBuffer(boundary: ⇒ Observable[Any]): Observable[Seq[T]]
Returns an Observable that emits non-overlapping buffered items from the source Observable each time the specified boundary Observable emits an item.
Returns an Observable that emits non-overlapping buffered items from the source Observable each time the specified boundary Observable emits an item.

Completion of either the source or the boundary Observable causes the returned Observable to emit the latest buffer and complete.
- boundary
the boundary Observable. Note: This is a by-name parameter, so it is only evaluated when someone subscribes to the returned Observable.
- returns
an Observable that emits buffered items from the source Observable when the boundary Observable emits an item
- Definition Classes
- Observable
-
def
tumblingBuffer(timespan: Duration, count: Int, scheduler: Scheduler): Observable[Seq[T]]
Creates an Observable which produces buffers of collected values.
Creates an Observable which produces buffers of collected values. This Observable produces connected non-overlapping buffers, each of a fixed duration specified by the
timespanargument or a maximum size specified by thecountargument (which ever is reached first). When the source Observable completes or encounters an error, the current buffer is emitted and the event is propagated.- timespan
The period of time each buffer is collecting values before it should be emitted, and replaced with a new buffer.
- count
The maximum size of each buffer before it should be emitted.
- scheduler
The rx.lang.scala.Scheduler to use when determining the end and start of a buffer.
- returns
An rx.lang.scala.Observable which produces connected non-overlapping buffers which are emitted after a fixed duration or when the buffer has reached maximum capacity (which ever occurs first).
- Definition Classes
- Observable
-
def
tumblingBuffer(timespan: Duration, count: Int): Observable[Seq[T]]
Creates an Observable which produces buffers of collected values.
Creates an Observable which produces buffers of collected values. This Observable produces connected non-overlapping buffers, each of a fixed duration specified by the
timespanargument or a maximum size specified by thecountargument (which ever is reached first). When the source Observable completes or encounters an error, the current buffer is emitted and the event is propagated.- timespan
The period of time each buffer is collecting values before it should be emitted, and replaced with a new buffer.
- count
The maximum size of each buffer before it should be emitted.
- returns
An rx.lang.scala.Observable which produces connected non-overlapping buffers which are emitted after a fixed duration or when the buffer has reached maximum capacity (which ever occurs first).
- Definition Classes
- Observable
-
def
tumblingBuffer(timespan: Duration, scheduler: Scheduler): Observable[Seq[T]]
Creates an Observable which produces buffers of collected values.
Creates an Observable which produces buffers of collected values.
This Observable produces connected non-overlapping buffers, each of a fixed duration specified by the
timespanargument. When the source Observable completes or encounters an error, the current buffer is emitted and the event is propagated.- timespan
The period of time each buffer is collecting values before it should be emitted, and replaced with a new buffer.
- scheduler
The rx.lang.scala.Scheduler to use when determining the end and start of a buffer.
- returns
An rx.lang.scala.Observable which produces connected non-overlapping buffers with a fixed duration.
- Definition Classes
- Observable
-
def
tumblingBuffer(timespan: Duration): Observable[Seq[T]]
Creates an Observable which produces buffers of collected values.
Creates an Observable which produces buffers of collected values.
This Observable produces connected non-overlapping buffers, each of a fixed duration specified by the
timespanargument. When the source Observable completes or encounters an error, the current buffer is emitted and the event is propagated.- timespan
The period of time each buffer is collecting values before it should be emitted, and replaced with a new buffer.
- returns
An rx.lang.scala.Observable which produces connected non-overlapping buffers with a fixed duration.
- Definition Classes
- Observable
-
def
tumblingBuffer(count: Int): Observable[Seq[T]]
Creates an Observable which produces buffers of collected values.
Creates an Observable which produces buffers of collected values.
This Observable produces connected non-overlapping buffers, each containing
countelements. When the source Observable completes or encounters an error, the current buffer is emitted, and the event is propagated.- count
The maximum size of each buffer before it should be emitted.
- returns
An rx.lang.scala.Observable which produces connected non-overlapping buffers containing at most
countproduced values.
- Definition Classes
- Observable
-
def
unsafeSubscribe(subscriber: Subscriber[T]): Subscription
Subscribe to Observable and invoke
OnSubscribefunction without any contract protection, error handling, unsubscribe, or execution hooks.Subscribe to Observable and invoke
OnSubscribefunction without any contract protection, error handling, unsubscribe, or execution hooks.This should only be used for implementing an
Operatorthat requires nested subscriptions.Normal use should use
Observable.subscribewhich ensures the Rx contract and other functionality.- returns
Subscription which is the Subscriber passed in
- Definition Classes
- Observable
- Since
0.17
-
def
unsubscribeOn(scheduler: Scheduler): Observable[T]
Asynchronously unsubscribes on the specified Scheduler.
Asynchronously unsubscribes on the specified Scheduler.
- scheduler
the Scheduler to perform subscription and unsubscription actions on
- returns
the source Observable modified so that its unsubscriptions happen on the specified Scheduler
- Definition Classes
- Observable
- Since
0.17
-
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
withFilter(p: (T) ⇒ Boolean): WithFilter[T]
- Definition Classes
- Observable
-
def
withLatestFrom[U, R](other: Observable[U])(resultSelector: (T, U) ⇒ R): Observable[R]
EXPERIMENTAL Merges the specified Observable into this Observable sequence by using the
resultSelectorfunction only when the source Observable (this instance) emits an item.EXPERIMENTAL Merges the specified Observable into this Observable sequence by using the
resultSelectorfunction only when the source Observable (this instance) emits an item.
Scheduler:
This method does not operate by default on a particular Scheduler.
- other
the other Observable
- resultSelector
the function to call when this Observable emits an item and the other Observable has already emitted an item, to generate the item to be emitted by the resulting Observable
- returns
an Observable that merges the specified Observable into this Observable by using the
resultSelectorfunction only when the source Observable sequence (this instance) emits an item
- Definition Classes
- Observable
- Annotations
- @Experimental()
- Since
(if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
- See also
-
def
zip[U](that: Iterable[U]): Observable[(T, U)]
Returns an Observable formed from
thisObservable andotherIterable by combining corresponding elements in pairs.Returns an Observable formed from
thisObservable andotherIterable by combining corresponding elements in pairs.
Note that the
otherIterable is evaluated as items are observed from the source Observable; it is not pre-consumed. This allows you to zip infinite streams on either side.- that
the Iterable sequence
- returns
an Observable that pairs up values from the source Observable and the
otherIterable.
- Definition Classes
- Observable
-
def
zip[U](that: Observable[U]): Observable[(T, U)]
Returns an Observable formed from this Observable and another Observable by combining corresponding elements in pairs.
Returns an Observable formed from this Observable and another Observable by combining corresponding elements in pairs. The number of
onNextinvocations of the resultingObservable[(T, U)]is the minumum of the number ofonNextinvocations ofthisandthat.- that
the Observable to zip with
- returns
an Observable that pairs up values from
thisandthatObservables.
- Definition Classes
- Observable
-
def
zipWith[U, R](that: Observable[U])(selector: (T, U) ⇒ R): Observable[R]
Returns an Observable formed from this Observable and another Observable by combining corresponding elements using the selector function.
Returns an Observable formed from this Observable and another Observable by combining corresponding elements using the selector function. The number of
onNextinvocations of the resultingObservable[(T, U)]is the minumum of the number ofonNextinvocations ofthisandthat.- that
the Observable to zip with
- returns
an Observable that pairs up values from
thisandthatObservables.
- Definition Classes
- Observable
-
def
zipWith[U, R](that: Iterable[U])(selector: (T, U) ⇒ R): Observable[R]
Returns an Observable that emits items that are the result of applying a specified function to pairs of values, one each from the source Observable and a specified Iterable sequence.
Returns an Observable that emits items that are the result of applying a specified function to pairs of values, one each from the source Observable and a specified Iterable sequence.

Note that the
otherIterable is evaluated as items are observed from the source Observable; it is not pre-consumed. This allows you to zip infinite streams on either side.- that
the Iterable sequence
- selector
a function that combines the pairs of items from the Observable and the Iterable to generate the items to be emitted by the resulting Observable
- returns
an Observable that pairs up values from the source Observable and the
otherIterable sequence and emits the results ofselectorapplied to these pairs
- Definition Classes
- Observable
-
def
zipWithIndex: Observable[(T, Int)]
Zips this Observable with its indices.
Zips this Observable with its indices.
- returns
An Observable emitting pairs consisting of all elements of this Observable paired with their index. Indices start at 0.
- Definition Classes
- Observable
Deprecated Value Members
-
def
cache(capacity: Int): Observable[T]
Caches emissions from the source Observable and replays them in order to any subsequent Subscribers.
Caches emissions from the source Observable and replays them in order to any subsequent Subscribers. This method has similar behavior to
Observable.replayexcept that this auto-subscribes to the source Observable rather than returning a ConnectableObservable for which you must callconnectto activate the subscription.
This is useful when you want an Observable to cache responses and you can't control the
subscribe/unsubscribebehavior of all the Subscribers.When you call
cache, it does not yet subscribe to the source Observable and so does not yet begin cacheing items. This only happens when the first Subscriber calls the resulting Observable'ssubscribemethod.Note: You sacrifice the ability to unsubscribe from the origin when you use the
cacheObserver so be careful not to use this Observer on Observables that emit an infinite or very large number of items that will use up memory.Backpressure Support:
This operator does not support upstream backpressure as it is purposefully requesting and caching everything emitted.
Scheduler:
cachedoes not operate by default on a particularScheduler.- capacity
hint for number of items to cache (for optimizing underlying data structure)
- returns
an Observable that, when first subscribed to, caches all of its items and notifications for the benefit of subsequent subscribers
- Definition Classes
- Observable
- Annotations
- @deprecated
- Deprecated
(Since version 0.26.1) Use Observable.cacheWithInitialCapacity instead
- Since
0.20
- See also
-
def
finallyDo(action: ⇒ Unit): Observable[T]
Registers an function to be called when this Observable invokes onCompleted or onError.
Registers an function to be called when this Observable invokes onCompleted or onError.
- action
an function to be invoked when the source Observable finishes
- returns
an Observable that emits the same items as the source Observable, then invokes the function
- Definition Classes
- Observable
- Annotations
- @deprecated
- Deprecated
(Since version 0.26.1) Use Observable.doAfterTerminate instead
-
def
flattenDelayError[U](implicit evidence: <:<[Observable[T], Observable[Observable[U]]]): Observable[U]
Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to receive all successfully emitted items from all of the source Observables without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to these Observables.
Flattens an Observable that emits Observables into one Observable, in a way that allows an Observer to receive all successfully emitted items from all of the source Observables without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to these Observables.
This behaves like
flattenexcept that if any of the merged Observables notify of an error viaonError,flattenDelayErrorwill refrain from propagating that error notification until all of the merged Observables have finished emitting items.
Even if multiple merged Observables send
onErrornotifications,flattenDelayErrorwill only invoke theonErrormethod of itsObservers once.Scheduler:
This method does not operate by default on a particular Scheduler.
- returns
an Observable that emits all of the items emitted by the Observables emitted by
this
- Definition Classes
- Observable
- Annotations
- @deprecated
- Deprecated
(Since version 0.26.2) Use delayError.flatten instead
- See also
-
def
mergeDelayError[U >: T](that: Observable[U]): Observable[U]
This behaves like rx.lang.scala.Observable.merge except that if any of the merged Observables notify of an error via onError,
mergeDelayErrorwill refrain from propagating that error notification until all of the merged Observables have finished emitting items.This behaves like rx.lang.scala.Observable.merge except that if any of the merged Observables notify of an error via onError,
mergeDelayErrorwill refrain from propagating that error notification until all of the merged Observables have finished emitting items.
Even if multiple merged Observables send
onErrornotifications,mergeDelayErrorwill only invoke theonErrormethod of its Observers once.This method allows an Observer to receive all successfully emitted items from all of the source Observables without being interrupted by an error notification from one of them.
- that
an Observable to be merged
- returns
an Observable that emits items that are the result of flattening the items emitted by
thisandthat
- Definition Classes
- Observable
- Annotations
- @deprecated
- Deprecated
(Since version 0.26.2) Use delayError.merge instead