RxViewModel

abstract class RxViewModel : ViewModel

Base class for a view model that stores a CompositeDisposable of all active subscriptions and destroys them on AndroidViewModel.onCleared

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
Link copied to clipboard
fun Completable.hot(): Completable

Caches the Completable and subscribes to it. The Completable will return it's result for any later subscriber as long as the ViewModel is alive (until the ViewModels onCleared method is called).

fun <T : Any> Maybe<T>.hot(): Maybe<T>

Caches the Maybe and subscribes to it. The Maybe will return it's result for any later subscriber as long as the ViewModel is alive (until the ViewModels onCleared method is called).

fun <T : Any> Single<T>.hot(): Single<T>

Caches the Single and subscribes to it. The Single will return it's result for any later subscriber as long as the ViewModel is alive (until the ViewModels onCleared method is called).

fun <T : Any> Flowable<T>.hot(cacheOnComplete: Boolean): Flowable<T>

Applies a replay(1).refCount() to the Flowable and subscribes to it. The Flowable will be alive as long as the ViewModel is alive (until the ViewModels onCleared method is called).

fun <T : Any> Observable<T>.hot(cacheOnComplete: Boolean = false): Observable<T>

Applies a replay(1).refCount() to the Observable and subscribes to it. The Observable will be alive as long as the ViewModel is alive (until the ViewModels onCleared method is called).

Link copied to clipboard
protected open override fun onCleared()

Properties

Link copied to clipboard
protected val keepAlive: CompositeDisposable

This CompositeDisposable will be disposed in onCleared() Therefore it survives orientation changes