orElseLazily

fun <T> Provider<T?>.orElseLazily(lazyValue: () -> T): Provider<T>

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

lazyValue should be a pure function.

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


fun <T : Any> MutableProvider<T?>.orElseLazily(lazyValue: () -> T): MutableProvider<T>

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

lazyValue should be a pure function.

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