MutableProvider

sealed interface MutableProvider<T> : Provider<T>

A MutableProvider is a Provider that allows setting the value.

Functions

Link copied to clipboard
abstract fun <R> flatMap(transform: (T) -> Provider<R>): Provider<R>

Creates and returns a new Provider that maps to the value of the Provider returned by transform.

Link copied to clipboard
inline fun <T, R> Provider<Collection<T>>.flatMapCollection(crossinline transform: (T) -> Iterable<R>): Provider<List<R>>

Creates and returns a new Provider that flat-maps the elements of the Collection obtained from this into a list using the transform function.

Link copied to clipboard
inline fun <T, R, C : MutableCollection<in R>> Provider<Collection<T>>.flatMapCollectionTo(crossinline makeCollection: (size: Int) -> C, crossinline transform: (T) -> Iterable<R>): Provider<C>

Creates and returns a new Provider that flat-maps the elements of the Collection obtained from this into a collection created by makeCollection using the transform function.

Link copied to clipboard
abstract fun <R> flatMapMutable(transform: (T) -> MutableProvider<R>): MutableProvider<R>

Creates and returns a new MutableProvider that maps to the value of the MutableProvider returned by transform.

Link copied to clipboard

Creates and returns a new Provider that maps to the provider that is the value of this.

Link copied to clipboard

Creates and returns a new Provider that flattens the List of Lists obtained from this.

Link copied to clipboard
abstract fun get(): T
Link copied to clipboard
@JvmName(name = "arrayGet")
operator fun <T> Provider<Array<T>>.get(index: Int): Provider<T>
@JvmName(name = "arrayGet")
operator fun <T> Provider<Array<T>>.get(index: Provider<Int>): Provider<T>
@JvmName(name = "listGet")
operator fun <T> Provider<List<T>>.get(index: Int): Provider<T>
@JvmName(name = "listGet")
operator fun <T> Provider<List<T>>.get(index: Provider<Int>): Provider<T>

Creates and returns a new Provider that maps to the element at index or throws NoSuchElementException.

Link copied to clipboard
@JvmName(name = "arrayGetCoerced")
fun <T> Provider<Array<T>>.getCoerced(index: Int): Provider<T>
@JvmName(name = "arrayGetCoerced")
fun <T> Provider<Array<T>>.getCoerced(index: Provider<Int>): Provider<T>
@JvmName(name = "listGetCoerced")
fun <T> Provider<List<T>>.getCoerced(index: Int): Provider<T>
@JvmName(name = "listGetCoerced")
fun <T> Provider<List<T>>.getCoerced(index: Provider<Int>): Provider<T>

Creates and returns a new Provider that maps to the element at index or the element at the closest valid index.

Link copied to clipboard
@JvmName(name = "arrayGetMod")
fun <T> Provider<Array<T>>.getMod(index: Int): Provider<T>
@JvmName(name = "arrayGetMod")
fun <T> Provider<Array<T>>.getMod(index: Provider<Int>): Provider<T>

Creates and returns a new Provider that maps to the element at index modulo the array size.

@JvmName(name = "listGetMod")
fun <T> Provider<List<T>>.getMod(index: Int): Provider<T>
@JvmName(name = "listGetMod")
fun <T> Provider<List<T>>.getMod(index: Provider<Int>): Provider<T>

Creates and returns a new Provider that maps to the element at index modulo the list size.

Link copied to clipboard
@JvmName(name = "arrayGetOrNull")
fun <T> Provider<Array<T>>.getOrNull(index: Int): Provider<T?>
@JvmName(name = "arrayGetOrNull")
fun <T> Provider<Array<T>>.getOrNull(index: Provider<Int>): Provider<T?>
@JvmName(name = "listGetOrNull")
fun <T> Provider<List<T>>.getOrNull(index: Int): Provider<T?>
@JvmName(name = "listGetOrNull")
fun <T> Provider<List<T>>.getOrNull(index: Provider<Int>): Provider<T?>

Creates and returns a new Provider that maps to the element at index or null if the index is out of bounds.

Link copied to clipboard
open operator fun <X> getValue(thisRef: X?, property: KProperty<*>?): T
Link copied to clipboard
abstract fun <R> lazyFlatMap(transform: (T) -> Provider<R>): Provider<R>

Creates and returns new Provider that lazily maps to the value of the Provider returned by transform.

Link copied to clipboard
abstract fun <R> lazyFlatMapMutable(transform: (T) -> MutableProvider<R>): MutableProvider<R>

Creates and returns new MutableProvider that lazily maps to the value of the MutableProvider returned by transform.

Link copied to clipboard
abstract fun <R> map(transform: (T) -> R, untransform: (R) -> T): MutableProvider<R>

Creates and returns a new MutableProvider that maps the value of this bi-directionally using the provided transform and untransform functions.

abstract fun <R> map(transform: (T) -> R): Provider<R>

Creates and returns a new Provider that maps the value of this using the transform function.

Link copied to clipboard
inline fun <T, R> Provider<Collection<T>>.mapEach(crossinline transform: (T) -> R): Provider<List<R>>

Creates and returns a new Provider that maps each element of the Collection obtained from this using the transform function.

Link copied to clipboard
inline fun <T, R : Any> Provider<Collection<T>>.mapEachNotNull(crossinline transform: (T) -> R?): Provider<List<R>>

Creates and returns a new Provider that maps each element of the Collection obtained from this using the transform function and filters out all null results.

Link copied to clipboard
inline fun <T, R : Any, C : MutableCollection<in R>> Provider<Collection<T>>.mapEachNotNullTo(crossinline makeCollection: (size: Int) -> C, crossinline transform: (T) -> R?): Provider<C>

Creates and returns a new Provider that maps each element of the Collection obtained from this using the transform function and filters out all null results. The results are added to a collection created by makeCollection.

Link copied to clipboard
inline fun <T, R, C : MutableCollection<in R>> Provider<Collection<T>>.mapEachTo(crossinline makeCollection: (size: Int) -> C, crossinline transform: (T) -> R): Provider<C>

Creates and returns a new Provider that maps each element of the Collection obtained from this using the transform function and adds the results to a collection created by makeCollection.

Link copied to clipboard
inline fun <T : Any, R> Provider<T?>.mapNonNull(crossinline transform: (T) -> R): Provider<R?>

Creates and returns a new Provider that maps non-null values of this using the transform function. Null values will be passed through without transformation.

inline fun <T : Any, R : Any> MutableProvider<T?>.mapNonNull(crossinline transform: (T) -> R?, crossinline untransform: (R) -> T?): MutableProvider<R?>

Creates and returns a new MutableProvider that maps non-null values of this bi-directionally using the provided transform and untransform functions. Null values will be passed through without transformation.

Link copied to clipboard
fun <K, V> Provider<List<Map<K, V>>>.mergeMaps(): Provider<Map<K, V>>

Creates and returns a new Provider that merges all Maps obtained from this into a single Map.

Link copied to clipboard
fun <K, V, M : MutableMap<in K, in V>> Provider<List<Map<K, V>>>.mergeMapsTo(makeMap: (size: Int) -> M): Provider<M>

Creates and returns a new Provider that merges all Maps obtained from this into a single Map, which is created by the makeMap function.

Link copied to clipboard
abstract fun observe(action: () -> Unit)

Registers a function that will be called whenever the value of this Provider changes.

Link copied to clipboard
@JvmName(name = "observedList")
fun <E> MutableProvider<out MutableList<E>>.observed(): Provider<MutableList<E>>

Creates and returns a new Provider that observes the list of this and propagates changes appropriately.

@JvmName(name = "observedMap")
fun <K, V> MutableProvider<out MutableMap<K, V>>.observed(): Provider<MutableMap<K, V>>

Creates and returns a new Provider that observes the map of this and propagates changes appropriately.

@JvmName(name = "observedSet")
fun <E> MutableProvider<out MutableSet<E>>.observed(): Provider<MutableSet<E>>

Creates and returns a new Provider that observes the set of this and propagates changes appropriately.

Link copied to clipboard
abstract fun <R : Any> observeWeak(owner: R, action: (owner: R) -> Unit)

Registers a weak observer that will be called when the value of this Provider changes. The observer will be automatically removed when the owner is garbage collected.

Link copied to clipboard

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.

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.

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.

@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.

Link copied to clipboard
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.

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.

Link copied to clipboard
fun <T> MutableProvider<T?>.orElseNew(newValue: () -> T): MutableProvider<T>

Creates a new MutableProvider that returns a fallback value which is re-created through the newValue lambda every time the value of this is set to null. Conversely, if the returned provider's value is set to a value equal to one returned by newValue, the value of this will be set to null.

fun <T> Provider<T?>.orElseNew(newValue: () -> T): Provider<T>

Creates a new Provider that returns a fallback value which is re-created through the newValue lambda every time the value of this is set to null.

Link copied to clipboard
inline fun <T> Provider<T>.require(crossinline condition: (T) -> Boolean, crossinline message: (T) -> String): Provider<T>

Creates and returns a new Provider that throws an IllegalArgumentException with a message generated by message if condition fails.

Link copied to clipboard
inline fun <T : Any> Provider<T?>.requireNotNull(crossinline message: () -> String): Provider<T>

Creates and returns a new Provider that throws an IllegalArgumentException with a message generated by message if the value is null.

fun <T : Any> Provider<T?>.requireNotNull(message: String = "Required value was null."): Provider<T>

Creates and returns a new Provider that throws an IllegalArgumentException with message if the value is null.

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

Sets the value of this MutableProvider to value.

Link copied to clipboard
open operator fun <X> setValue(thisRef: X?, property: KProperty<*>, value: T)
Link copied to clipboard
abstract fun <R> strongFlatMap(transform: (T) -> Provider<R>): Provider<R>

Creates and returns a new Provider that maps to the value of the Provider returned by transform.

Link copied to clipboard
inline fun <T, R> Provider<Collection<T>>.strongFlatMapCollection(crossinline transform: (T) -> Iterable<R>): Provider<List<R>>

Creates and returns a new Provider that flat-maps the elements of the Collection obtained from this into a list using the transform function.

Link copied to clipboard
inline fun <T, R, C : MutableCollection<in R>> Provider<Collection<T>>.strongFlatMapCollectionTo(crossinline makeCollection: (size: Int) -> C, crossinline transform: (T) -> Iterable<R>): Provider<C>

Creates and returns a new Provider that flat-maps the elements of the Collection obtained from this into a collection created by makeCollection using the transform function.

Link copied to clipboard
abstract fun <R> strongFlatMapMutable(transform: (T) -> MutableProvider<R>): MutableProvider<R>

Creates and returns a new MutableProvider that maps to the value of the MutableProvider returned by transform.

Link copied to clipboard

Creates and returns a new Provider that maps to the provider that is the value of this.

Link copied to clipboard

Creates and returns a new Provider that flattens the List of Lists obtained from this.

Link copied to clipboard
@JvmName(name = "strongArrayGet")
fun <T> Provider<Array<T>>.strongGet(index: Int): Provider<T>
@JvmName(name = "strongArrayGet")
fun <T> Provider<Array<T>>.strongGet(index: Provider<Int>): Provider<T>
@JvmName(name = "strongListGet")
fun <T> Provider<List<T>>.strongGet(index: Int): Provider<T>
@JvmName(name = "strongListGet")
fun <T> Provider<List<T>>.strongGet(index: Provider<Int>): Provider<T>

Creates and returns a new Provider that maps to the element at index or throws NoSuchElementException.

Link copied to clipboard
@JvmName(name = "strongArrayGetCoerced")
fun <T> Provider<Array<T>>.strongGetCoerced(index: Int): Provider<T>
@JvmName(name = "strongArrayGetCoerced")
fun <T> Provider<Array<T>>.strongGetCoerced(index: Provider<Int>): Provider<T>
@JvmName(name = "strongListGetCoerced")
fun <T> Provider<List<T>>.strongGetCoerced(index: Int): Provider<T>
@JvmName(name = "strongListGetCoerced")
fun <T> Provider<List<T>>.strongGetCoerced(index: Provider<Int>): Provider<T>

Creates and returns a new Provider that maps to the element at index or the element at the closest valid index.

Link copied to clipboard
@JvmName(name = "strongArrayGetMod")
fun <T> Provider<Array<T>>.strongGetMod(index: Int): Provider<T>
@JvmName(name = "strongArrayGetMod")
fun <T> Provider<Array<T>>.strongGetMod(index: Provider<Int>): Provider<T>

Creates and returns a new Provider that maps to the element at index modulo the array size.

@JvmName(name = "strongListGetMod")
fun <T> Provider<List<T>>.strongGetMod(index: Int): Provider<T>
@JvmName(name = "strongListGetMod")
fun <T> Provider<List<T>>.strongGetMod(index: Provider<Int>): Provider<T>

Creates and returns a new Provider that maps to the element at index modulo the list size.

Link copied to clipboard
@JvmName(name = "strongArrayGetOrNull")
fun <T> Provider<Array<T>>.strongGetOrNull(index: Int): Provider<T?>
@JvmName(name = "strongArrayGetOrNull")
fun <T> Provider<Array<T>>.strongGetOrNull(index: Provider<Int>): Provider<T?>
@JvmName(name = "strongListGetOrNull")
fun <T> Provider<List<T>>.strongGetOrNull(index: Int): Provider<T?>
@JvmName(name = "strongListGetOrNull")
fun <T> Provider<List<T>>.strongGetOrNull(index: Provider<Int>): Provider<T?>

Creates and returns a new Provider that maps to the element at index or null if the index is out of bounds.

Link copied to clipboard
abstract fun <R> strongLazyFlatMap(transform: (T) -> Provider<R>): Provider<R>

Creates and returns new Provider that lazily maps to the value of the Provider returned by transform.

Link copied to clipboard
abstract fun <R> strongLazyFlatMapMutable(transform: (T) -> MutableProvider<R>): MutableProvider<R>

Creates and returns new MutableProvider that lazily maps to the value of the MutableProvider returned by transform.

Link copied to clipboard
abstract fun <R> strongMap(transform: (T) -> R, untransform: (R) -> T): MutableProvider<R>

Creates and returns a new MutableProvider that maps the value of this bi-directionally using the provided transform and untransform functions.

abstract fun <R> strongMap(transform: (T) -> R): Provider<R>

Creates and returns a new Provider that maps the value of this using the transform function.

Link copied to clipboard
inline fun <T, R> Provider<Collection<T>>.strongMapEach(crossinline transform: (T) -> R): Provider<List<R>>

Creates and returns a new Provider that maps each element of the Collection obtained from this using the transform function.

Link copied to clipboard
inline fun <T, R : Any> Provider<Collection<T>>.strongMapEachNotNull(crossinline transform: (T) -> R?): Provider<List<R>>

Creates and returns a new Provider that maps each element of the Collection obtained from this using the transform function and filters out all null results.

Link copied to clipboard
inline fun <T, R : Any, C : MutableCollection<in R>> Provider<Collection<T>>.strongMapEachNotNullTo(crossinline makeCollection: (size: Int) -> C, crossinline transform: (T) -> R?): Provider<C>

Creates and returns a new Provider that maps each element of the Collection obtained from this using the transform function and filters out all null results. The results are added to a collection created by makeCollection.

Link copied to clipboard
inline fun <T, R, C : MutableCollection<in R>> Provider<Collection<T>>.strongMapEachTo(crossinline makeCollection: (size: Int) -> C, crossinline transform: (T) -> R): Provider<C>

Creates and returns a new Provider that maps each element of the Collection obtained from this using the transform function and adds the results to a collection created by makeCollection.

Link copied to clipboard
inline fun <T : Any, R> Provider<T?>.strongMapNonNull(crossinline transform: (T) -> R): Provider<R?>

Creates and returns a new Provider that maps non-null values of this using the transform function. Null values will be passed through without transformation.

inline fun <T : Any, R : Any> MutableProvider<T?>.strongMapNonNull(crossinline transform: (T) -> R?, crossinline untransform: (R) -> T?): MutableProvider<R?>

Creates and returns a new MutableProvider that maps non-null values of this bi-directionally using the provided transform and untransform functions. Null values will be passed through without transformation.

Link copied to clipboard

Creates and returns a new Provider that merges all Maps obtained from this into a single Map.

Link copied to clipboard
fun <K, V, M : MutableMap<in K, in V>> Provider<List<Map<K, V>>>.strongMergeMapsTo(makeMap: (size: Int) -> M): Provider<M>

Creates and returns a new Provider that merges all Maps obtained from this into a single Map, which is created by the makeMap function.

Link copied to clipboard
@JvmName(name = "strongObservedList")
fun <E> MutableProvider<out MutableList<E>>.strongObserved(): Provider<MutableList<E>>

Creates and returns a new Provider that observes the list of this and propagates changes appropriately.

@JvmName(name = "strongObservedMap")
fun <K, V> MutableProvider<out MutableMap<K, V>>.strongObserved(): Provider<MutableMap<K, V>>

Creates and returns a new Provider that observes the map of this and propagates changes appropriately.

@JvmName(name = "strongObservedSet")
fun <E> MutableProvider<out MutableSet<E>>.strongObserved(): Provider<MutableSet<E>>

Creates and returns a new Provider that observes the set of this and propagates changes appropriately.

Link copied to clipboard

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.

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

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

fun <T> Provider<T?>.strongOrElse(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.

@JvmName(name = "strongOrElseNullable")
fun <T> Provider<T?>.strongOrElse(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.

Link copied to clipboard
fun <T : Any> MutableProvider<T?>.strongOrElseLazily(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.

fun <T> Provider<T?>.strongOrElseLazily(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.

Link copied to clipboard
fun <T> MutableProvider<T?>.strongOrElseNew(newValue: () -> T): MutableProvider<T>

Creates a new MutableProvider that returns a fallback value which is re-created through the newValue lambda every time the value of this is set to null. Conversely, if the returned provider's value is set to a value equal to one returned by newValue, the value of this will be set to null.

fun <T> Provider<T?>.strongOrElseNew(newValue: () -> T): Provider<T>

Creates a new Provider that returns a fallback value which is re-created through the newValue lambda every time the value of this is set to null.

Link copied to clipboard
inline fun <T> Provider<T>.strongRequire(crossinline condition: (T) -> Boolean, crossinline message: (T) -> String): Provider<T>

Creates and returns a new Provider that throws an IllegalArgumentException with a message generated by message if condition fails.

Link copied to clipboard
inline fun <T : Any> Provider<T?>.strongRequireNotNull(crossinline message: () -> String): Provider<T>

Creates and returns a new Provider that throws an IllegalArgumentException with a message generated by message if the value is null.

fun <T : Any> Provider<T?>.strongRequireNotNull(message: String = "Required value was null."): Provider<T>

Creates and returns a new Provider that throws an IllegalArgumentException with message if the value is null.

Link copied to clipboard
abstract fun subscribe(action: (value: T) -> Unit)

Registers a function that will be called with the new value whenever the value of this Provider changes.

Link copied to clipboard
abstract fun <R : Any> subscribeWeak(owner: R, action: (owner: R, value: T) -> Unit)

Registers a weak subscriber that will be called when the value of this Provider changes. The subscriber will be automatically removed when the owner is garbage collected.

Link copied to clipboard
abstract fun unobserve(action: () -> Unit)

Removes a previously registered observer.

Link copied to clipboard
abstract fun <R : Any> unobserveWeak(owner: R)

Removes all weak observers under the given owner.

abstract fun <R : Any> unobserveWeak(owner: R, action: (R) -> Unit)

Removes a previously registered weak observer.

Link copied to clipboard
abstract fun unsubscribe(action: (T) -> Unit)

Removes a previously registered subscriber.

Link copied to clipboard
abstract fun <R : Any> unsubscribeWeak(owner: R)

Removes all weak subscribers under the given owner.

abstract fun <R : Any> unsubscribeWeak(owner: R, action: (R, T) -> Unit)

Removes a previously registered weak subscriber.