SingleWrapper

open class SingleWrapper<out T : Any>(inner: Single<T>) : Single<T>

Wrappers are normally exposed to Swift. You can also extend the wrapper class if you need to expose any additional operators.

Constructors

Link copied to clipboard
constructor(inner: Single<T>)

Functions

Link copied to clipboard

Returns a Completable that ignores the success value of this Single and signals onComplete instead.

Link copied to clipboard
fun <T> Single<T>.asMaybe(): Maybe<T>

Converts this Single into a Maybe, which signals either onSuccess or onError.

Link copied to clipboard

Converts this Single into an Observable, which signals the success value via onNext followed by onComplete.

Link copied to clipboard
Link copied to clipboard
fun <T> Single<T>.blockingGet(): T

Blocks current thread until the current Single succeeds with a value (which is returned) or fails with an exception (which is propagated).

Link copied to clipboard
fun <T> Single<T>.delay(delay: Duration, scheduler: Scheduler, delayError: Boolean = false): Single<T>

Delays onSuccess signal from the current Single for the specified time. The onError signal is not delayed by default, which can be enabled by setting the delayError flag.

Link copied to clipboard
fun <T> Single<T>.delaySubscription(delay: Duration, scheduler: Scheduler): Single<T>

Delays the actual subscription to the Single for the specified time.

Link copied to clipboard
fun <T> Single<T>.doOnAfterDispose(action: () -> Unit): Single<T>

Calls the shared action when the Disposable sent to the observer via onSubscribe is disposed. The action is called after the upstream is disposed.

Link copied to clipboard
fun <T> Single<T>.doOnAfterError(consumer: (Throwable) -> Unit): Single<T>

Calls the consumer with the emitted Throwable when the Single signals onError. The consumer is called after the observer is called.

Link copied to clipboard
fun <T> Single<T>.doOnAfterFinally(action: () -> Unit): Single<T>

Calls the action when one of the following events occur:

Link copied to clipboard

Calls the shared action for each new observer with the Disposable sent to the downstream. The action is called for each new observer after its onSubscribe callback is called.

Link copied to clipboard
fun <T> Single<T>.doOnAfterSuccess(action: (T) -> Unit): Single<T>

Calls the action with the emitted value when the Single signals onSuccess. The action is called after the observer is called.

Link copied to clipboard
fun <T> Single<T>.doOnAfterTerminate(action: () -> Unit): Single<T>

Calls the action when the Single signals a terminal event: either onSuccess or onError. The action is called after the observer is called.

Link copied to clipboard
fun <T> Single<T>.doOnBeforeDispose(action: () -> Unit): Single<T>

Calls the shared action when the Disposable sent to the observer via onSubscribe is disposed. The action is called before the upstream is disposed.

Link copied to clipboard
fun <T> Single<T>.doOnBeforeError(consumer: (Throwable) -> Unit): Single<T>

Calls the consumer with the emitted Throwable when the Single signals onError. The consumer is called before the observer is called.

Link copied to clipboard
fun <T> Single<T>.doOnBeforeFinally(action: () -> Unit): Single<T>

Calls the action when one of the following events occur:

Link copied to clipboard

Calls the shared action for each new observer with the Disposable sent to the downstream. The action is called for each new observer before its onSubscribe callback is called.

Link copied to clipboard
fun <T> Single<T>.doOnBeforeSuccess(consumer: (T) -> Unit): Single<T>

Calls the consumer with the emitted value when the Single signals onSuccess. The consumer is called before the observer is called.

Link copied to clipboard
fun <T> Single<T>.doOnBeforeTerminate(action: () -> Unit): Single<T>

Calls the action when the Single signals a terminal event: either onSuccess or onError. The action is called before the observer is called.

Link copied to clipboard
fun <T> Single<T>.filter(predicate: (T) -> Boolean): Maybe<T>

Filters the value emitted by the Single using the provided predicate. The returned Maybe signals onSuccess if the predicate returned true, otherwise signals onComplete.

Link copied to clipboard
fun <T, R> Single<T>.flatMap(mapper: (T) -> Single<R>): Single<R>

Calls the mapper with the value emitted by the Single and subscribes to the returned inner Single. Emits the value from the inner Single.

fun <T, U, R> Single<T>.flatMap(resultSelector: (T, U) -> R, mapper: (T) -> Single<U>): Single<R>

Calls the mapper with the value emitted by the Single and subscribes to the returned inner Single. When the inner Single emits, calls the resultSelector function with the original and the inner values and emits the result.

Link copied to clipboard

Calls the mapper with the value emitted by the Single and subscribes to the returned inner Completable.

Link copied to clipboard
fun <T, R> Single<T>.flatMapIterable(transformer: (T) -> Iterable<R>): Observable<R>

Calls the transformer with the value emitted by the Single and emits the returned Iterable values one by one as Observable.

Link copied to clipboard
fun <T, R> Single<T>.flatMapMaybe(mapper: (T) -> Maybe<R>): Maybe<R>

Calls the mapper with the value emitted by the Single and subscribes to the returned inner Maybe. Emits the value from the inner Maybe or completes.

fun <T, U, R> Single<T>.flatMapMaybe(mapper: (T) -> Maybe<U>, resultSelector: (T, U) -> R): Maybe<R>

Calls the mapper with the value emitted by the Single and subscribes to the returned inner Maybe. When the inner Maybe emits, calls the resultSelector function with the original and the inner values and emits the result. Completes if the inner Maybe completed.

Link copied to clipboard
fun <T, R> Single<T>.flatMapObservable(mapper: (T) -> Observable<R>): Observable<R>

Calls the mapper with the value emitted by the Single and subscribes to the returned inner Observable. Emits values from the inner Observable.

fun <T, U, R> Single<T>.flatMapObservable(mapper: (T) -> Observable<U>, resultSelector: (T, U) -> R): Observable<R>

Calls the mapper with the value emitted by the Single and subscribes to the returned inner Observable. For each value emitted by the inner Observable, calls the resultSelector function with the original and the inner values and emits the result.

Link copied to clipboard
@JvmName(name = "flattenObservable")
fun <T> Single<Observable<T>>.flatten(): Observable<T>

This is just a shortcut for Single.flatMapObservable.

When the Single emits an Iterable of values, iterates over the Iterable and emits all values one by one as an Observable.

Link copied to clipboard
fun <T, R> Single<T>.map(mapper: (T) -> R): Single<R>

Converts the value emitted by the Single using the provided mapper and emits the result.

Link copied to clipboard
fun <T, R> Single<Iterable<T>>.mapIterable(mapper: (T) -> R): Single<List<R>>

Converts values of the Iterable emitted by the Single using the provided mapper and emits the resulting values as List.

Link copied to clipboard
fun <T, R, C : MutableCollection<R>> Single<Iterable<T>>.mapIterableTo(collectionSupplier: () -> C, mapper: (T) -> R): Single<C>

Same as mapIterable but saves resulting values into a MutableCollection returned by collectionSupplier.

Link copied to clipboard
fun <T, R : Any> Single<T>.mapNotNull(mapper: (T) -> R?): Maybe<R>

Same as Single.map but returns a Maybe which emits the resulting value only if it is not null, otherwise completes.

Link copied to clipboard
fun <T : Any> Single<T?>.notNull(): Maybe<T>

Returns a Maybe that emits the value emitted by this Single only if it is not null, completes otherwise.

Link copied to clipboard
fun <T> Single<T>.observeOn(scheduler: Scheduler): Single<T>

Signals all events of the Single on the specified Scheduler.

Link copied to clipboard
inline fun <T> Single<*>.ofType(): Maybe<T>

Returns Maybe that emits the success value of this Single if it is an instance of T, otherwise completes.

Link copied to clipboard

When the Single signals onError, resumes the flow with next.

fun <T> Single<T>.onErrorResumeNext(nextSupplier: (Throwable) -> Single<T>): Single<T>

When the Single signals onError, resumes the flow with a new Single returned by nextSupplier.

Link copied to clipboard
fun <T> Single<T>.onErrorReturn(valueSupplier: (Throwable) -> T): Single<T>

When the Single signals onError, emits a value returned by valueSupplier.

Link copied to clipboard
fun <T> Single<T>.onErrorReturnValue(value: T): Single<T>

When the Single signals onError, emits the value.

Link copied to clipboard
fun <T> Single<T>.repeat(times: Long = Long.MAX_VALUE): Observable<T>

When the Single signals onSuccess, re-subscribes to the Single, times times.

Link copied to clipboard
fun <T> Single<T>.repeatUntil(predicate: (T) -> Boolean): Observable<T>

When the Single signals onSuccess, re-subscribes to the Single if the predicate function returns false.

Link copied to clipboard
fun <T> Single<T>.repeatWhen(handler: (attempt: Int, value: T) -> Maybe<*>): Observable<T>

When the Single signals onSuccess, re-subscribes to the Single when the Maybe returned by the handler function emits a value.

Link copied to clipboard
fun <T> Single<T>.retry(predicate: (attempt: Long, Throwable) -> Boolean = { _, _ -> true }): Single<T>

When the Single signals onError, re-subscribes to the Single if the predicate returns true.

fun <T> Single<T>.retry(times: Int): Single<T>

When the Single signals onError, re-subscribes to the Single, up to times times.

Link copied to clipboard
fun <T> Single<T>.retryWhen(handler: (Observable<Throwable>) -> Observable<*>): Single<T>

Returns a Single that automatically resubscribes to this Single if it signals onError and the Observable returned by the handler function emits a value for that specific Throwable.

Link copied to clipboard
open override fun subscribe(observer: SingleObserver<T>)

Subscribes the specified Observer to this Source

fun subscribe(onSuccess: (T) -> Unit): Disposable
fun subscribe(onError: (Throwable) -> Unit, onSuccess: (T) -> Unit): Disposable
fun subscribe(onSubscribe: (Disposable) -> Unit? = null, onError: (Throwable) -> Unit? = null, onSuccess: (T) -> Unit? = null): Disposable
Link copied to clipboard
fun <T> Single<T>.subscribe(onSubscribe: (Disposable) -> Unit? = null, onError: (Throwable) -> Unit? = null, onSuccess: (T) -> Unit? = null): Disposable

Subscribes to the Single and provides event callbacks.

Link copied to clipboard
fun <T> Single<T>.subscribeOn(scheduler: Scheduler): Single<T>

Returns a Single that subscribes to the source Single on the specified Scheduler.

Link copied to clipboard
fun <T> Single<T>.timeout(timeout: Duration, scheduler: Scheduler, other: Single<T>? = null): Single<T>

Disposes the current Single if it does not signal within the timeout, and subscribes to other if provided.

Link copied to clipboard
Link copied to clipboard
fun <T, R, I> Single<T>.zipWith(other: Single<R>, mapper: (T, R) -> I): Single<I>

Subscribes to both the current Single and the other, accumulates their values and emits a value returned by the mapper function.