ReplaySubject

interface ReplaySubject<T> : Subject<T>

A ReplaySubject is a specialized Subject that also maintains the latest N emissions in a cache. Upon subscription, all values in the cache will be emitted to the subscriber.

New values can be emitted to subscribers via the Observer.onNext method.

Properties

Link copied to clipboard
abstract val count: Int

Returns the number of subscribers to this Subject

Functions

Link copied to clipboard
abstract fun asObservable(): Observable<T>

Returns this Subject as an Observable to restrict publishing.

Link copied to clipboard
open fun asSingle(scheduler: Scheduler): Single<T>

Converts this Observable to a Single subscribing on the given Scheduler

Link copied to clipboard
open fun <R> async(block: (T, Observer<R>) -> Disposable): Observable<R>

Returns an observable that will emit values in a possibly asynchronous manner determined by the given block.

Link copied to clipboard
open fun buffered(count: Int): Observable<T>

Returns an observable that will buffer emissions until the buffer is full, at which point they will be emitted downstream.

Link copied to clipboard
open fun <R> callback(block: (T, Observer<R>) -> Unit): Observable<R>

Returns an observable that will emit values in a possibly asynchronous manner determined by the given block.

Link copied to clipboard
abstract fun clear()

Removes all currently cached values from this Subject. Future subscribers will no longer received the current entries upon subscribing.

Link copied to clipboard
open fun <T2, R> combine(other: Observable<T2>, combiner: (T, T2) -> R): Observable<R>

Returns an observable that combines the emissions of this observable the given other. The downstream emission is the result of applying the combiner function to the latest emissions of both observables - and are only possible once both this and the other have emitted at least one value.

open fun <T2, T3, R> combine(other1: Observable<T2>, other2: Observable<T3>, combiner: (T, T2, T3) -> R): Observable<R>

Returns an observable that combines the emissions of this observable the given others. The downstream emission is the result of applying the combiner function to the latest emissions of both observables - and are only possible once all others have emitted at least one value.

Link copied to clipboard
open fun distinct(): Observable<T>

Returns an observable that only emits downstream when the newest emissions is not equal to the previous emission. Emissions will be compared using standard Objects.equals

open fun distinct(isEquals: (T, T) -> Boolean): Observable<T>

Returns an observable that only emits downstream when the newest emissions is not equal to the previous emission. Emissions will be compared using the provided isEquals function

Link copied to clipboard
open fun filter(predicate: (T) -> Boolean): Observable<T>

Returns an observable that filters out emissions that do not match the given predicate

Link copied to clipboard

Convenience method for converting an observable of nullable items, into an observable of non-nullable items.

Link copied to clipboard
open fun <R> flatMap(transform: (T) -> Observable<R>): Observable<R>

Returns an observable that applies the given transform to the source emissions to produce new observables - all emissions from the resulting observables will be emitted downstream.

Link copied to clipboard
open fun <R> flatMapLatest(transform: (T) -> Observable<R>): Observable<R>

Returns an observable that applies the given transform to the source emissions to produce a new observable - only emissions from the latest observable created by the transform will be emitted downstream.

Link copied to clipboard
open fun forEach(block: (T) -> Unit): Observable<T>

Returns an observable that will call the given block with each source emission, before passing the original emission downstream.

Link copied to clipboard
abstract fun last(): T?

Attempts to return the last item that was published.

Link copied to clipboard
open fun <R> map(transform: (T) -> R): Observable<R>

Returns an observable that applies the given transform to each emission before passing it downstream.

Link copied to clipboard
open fun <R> mapNotNull(transform: (T) -> R?): Observable<R>

Returns an observable that applies the given transform to each emission before passing it downstream. Only emissions that are non-null after the application of the transform will be emitted downstream.

Link copied to clipboard

Convenience method that maps any incoming emission to Unit

Link copied to clipboard
open fun merge(other: Observable<T>): Observable<T>

Returns an observable that will propagate all source emissions downstream from this observable and from the given other.

Link copied to clipboard
open fun observeOn(scheduler: Scheduler): Observable<T>

Returns an observable that propagates emissions downstream on the given scheduler

Link copied to clipboard
abstract fun onNext(value: T)

Called whenever there has been a new item emitted by the upstream Observable.

Link copied to clipboard
abstract fun resize(size: Int)

Resizes the max cache size to the given size. If the new size is smaller than the current cache size, then old entries will be evicted to make space.

Link copied to clipboard
open fun resubscribingWhile(predicate: (T) -> Boolean): Observable<T>

Returns an observable that will continually resubscribe until the predicate returns false.

Link copied to clipboard
open fun share(): Observable<T>
open fun share(replay: Int): Observable<T>

Returns an Observable that will share a single connection to the source Observable (this).

Link copied to clipboard
open fun startWith(vararg item: T): Observable<T>

Returns an observable that will emit all the given item values before making a subscription to the source observable.

Link copied to clipboard
abstract fun subscribe(observer: Observer<T>): Disposable

Subscribes the given observer to receive updates

Link copied to clipboard
open fun subscribeOn(scheduler: Scheduler): Observable<T>

Returns an observable that performs the subscription on the given scheduler

Link copied to clipboard
open fun subscribeOnce(observer: Observer<T>): Disposable

Subscribes the given observer to a single emission of the source.

Link copied to clipboard
open fun take(count: Int): Observable<T>

Returns an observable that emits only the specified number of events given by the provided count

Link copied to clipboard
open fun takeWhile(predicate: (T) -> Boolean): Observable<T>
open fun takeWhile(inclusive: Boolean, predicate: (T) -> Boolean): Observable<T>

Returns an observable that emits downstream up until the predicate returns false.