orElse

fun <T> Provider<T?>.orElse(value: T): Provider<T>

Creates and returns a new Provider that returns a fallback value if the value of this is null.

The returned provider will only be stored in a WeakReference in the parent provider (this).


fun <T> Provider<T?>.orElse(provider: Provider<T>): Provider<T>

Creates and returns a new Provider that returns a fallback value obtained through provider if the value of this is null.

The returned provider will only be stored in a WeakReference in the parent providers (this and provider).


@JvmName(name = "orElseNullable")
fun <T> Provider<T?>.orElse(provider: Provider<T>?): Provider<T?>

If provider is null, returns this. If provider is not null, creates and returns a new Provider that returns a fallback value obtained through provider if the value of this is null.

The returned provider will only be stored in a WeakReference in the parent providers (this and provider).


Creates a new MutableProvider that returns a fallback value if the value of this is null. Conversely, if the returned provider's value is set a value equal to value, the value of this will be set to null.

The returned provider will only be stored in a WeakReference in the parent provider (this).