toDefaultSubject

fun <R : T, T> MutableStateFlow<T?>.toDefaultSubject(defaultValue: R, coroutineScope: CoroutineScope, context: CoroutineContext = coroutineScope.coroutineContext): StateFlowDefaultSubject<R, T>

Converts a MutableStateFlow to a StateFlowDefaultSubject

Parameters

defaultValue

The default value of R to observe if the MutableStateFlow emits null.

coroutineScope

The CoroutineScope on which to observe the MutableStateFlow

context

The CoroutineContext in which to observe the MutableStateFlow


fun <R : T?, T> MutableSharedFlow<T?>.toDefaultSubject(defaultValue: R, initialValue: T? = defaultValue, coroutineScope: CoroutineScope, context: CoroutineContext = coroutineScope.coroutineContext): SharedFlowDefaultSubject<R, T?>

Converts a MutableSharedFlow to a SharedFlowDefaultSubject

Parameters

defaultValue

The default value of R to observe if the MutableSharedFlow emits null.

initialValue

The initial value to observe until the MutableSharedFlow emits.

coroutineScope

The CoroutineScope on which to observe the MutableSharedFlow

context

The CoroutineContext in which to observe the MutableSharedFlow


fun <R : T, T> ReadWriteProperty<Any?, T?>.toDefaultSubject(defaultValue: R, coroutineScope: CoroutineScope? = null, context: CoroutineContext? = coroutineScope?.coroutineContext): ReadWritePropertyDefaultSubject<R, T?>

Converts a ReadWriteProperty to a ReadWritePropertyDefaultSubject

Parameters

defaultValue

The default value of R to observe if the ReadWriteProperty has a value of null.

coroutineScope

The CoroutineScope on which to emit changes to the ReadWriteProperty

context

The CoroutineContext in which to emit changes to the ReadWriteProperty