SpecialMutableStateFlow

open class SpecialMutableStateFlow<T>(initialValue: T, internalScope: CoroutineScope = CoroutineScope(Dispatchers.Default)) : MutableStateFlow<T> , FlowCollector<T> , MutableSharedFlow<T> (source)

Works like StateFlow, but guarantee that latest value update will always be delivered to each active subscriber

Constructors

Link copied to clipboard
constructor(initialValue: T, internalScope: CoroutineScope = CoroutineScope(Dispatchers.Default))

Properties

Link copied to clipboard
open override val replayCache: List<T>
Link copied to clipboard
open override val subscriptionCount: StateFlow<Int>
Link copied to clipboard
open override var value: T

Functions

Link copied to clipboard
fun <T> Flow<T>.accumulatorFlow(scope: CoroutineScope): Flow<T>

Creates AccumulatorFlow using this as base Flow

Link copied to clipboard
inline fun <T> Flow<List<T>>.asComposeList(scope: CoroutineScope, useContextOnChange: CoroutineContext? = Dispatchers.Main, noinline onException: ExceptionHandler<List<T>?> = defaultSafelyWithoutExceptionHandlerWithNull): List<T>

In fact, it is just classcast of asMutableComposeListState to List

Link copied to clipboard
inline fun <T> StateFlow<T>.asComposeState(scope: CoroutineScope, useContextOnChange: CoroutineContext? = Dispatchers.Main, noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull): <Error class: unknown class><T>

Will map this as State. This conversation will pass its StateFlow.value as the first value

fun <T> Flow<T>.asComposeState(initial: T, scope: CoroutineScope, useContextOnChange: CoroutineContext? = Dispatchers.Main, onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull): <Error class: unknown class><T>

Will create MutableState using asMutableComposeState and use asState to convert it as immutable state

Link copied to clipboard
inline fun <T> Flow<List<T>>.asMutableComposeListState(scope: CoroutineScope, useContextOnChange: CoroutineContext? = Dispatchers.Main, noinline onException: ExceptionHandler<List<T>?> = defaultSafelyWithoutExceptionHandlerWithNull): <Error class: unknown class><T>

Each value of this will trigger applyDiff to the result SnapshotStateList

Link copied to clipboard
inline fun <T> StateFlow<T>.asMutableComposeState(scope: CoroutineScope, useContextOnChange: CoroutineContext? = Dispatchers.Main, noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull): <Error class: unknown class><T>

Will map this as MutableState. Returned MutableState WILL NOT change source StateFlow. This conversation will pass its StateFlow.value as the first value

fun <T> Flow<T>.asMutableComposeState(initial: T, scope: CoroutineScope, useContextOnChange: CoroutineContext? = Dispatchers.Main, onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull): <Error class: unknown class><T>

Will map this as MutableState. Returned MutableState WILL NOT change source Flow

Link copied to clipboard
open suspend override fun collect(collector: FlowCollector<T>): Nothing
Link copied to clipboard
open override fun compareAndSet(expect: T, update: T): Boolean
Link copied to clipboard
open suspend override fun emit(value: T)
Link copied to clipboard
fun <T> Flow<T>.filterNotNull(): Flow<T & Any>
Link copied to clipboard
suspend fun <T> Flow<T?>.firstNotNull(): T
Link copied to clipboard
@JvmName(name = "flatMapIterable")
inline fun <T, R> Flow<Iterable<T>>.flatMap(crossinline mapper: suspend (T) -> R): Flow<R>
inline fun <T, R> Flow<Flow<T>>.flatMap(crossinline mapper: suspend (T) -> R): Flow<R>
Link copied to clipboard
@JvmName(name = "flatMapNotNullIterable")
inline fun <T, R> Flow<Iterable<T>>.flatMapNotNull(crossinline mapper: suspend (T) -> R): Flow<R & Any>
inline fun <T, R> Flow<Flow<T>>.flatMapNotNull(crossinline mapper: suspend (T) -> R): Flow<R & Any>
Link copied to clipboard
@JvmName(name = "flattenIterable")
fun <T> Flow<Iterable<T>>.flatten(): Flow<T>
fun <T> Flow<Flow<T>>.flatten(): Flow<T>
Link copied to clipboard
inline suspend operator fun <T> FlowCollector<T>.invoke(value: T)
Link copied to clipboard
inline fun Flow<Int>.mapLeftItems(crossinline countGetter: () -> Int): Flow<Int>
Link copied to clipboard
inline fun Flow<Int>.mapRequireFilling(minimalLeftItems: Int, crossinline countGetter: () -> Int): Flow<Int>
Link copied to clipboard
inline operator fun <T> Flow<T>.plus(other: Flow<T>): Flow<T>
Link copied to clipboard
@ExperimentalCoroutinesApi
open override fun resetReplayCache()
Link copied to clipboard
inline fun <T> Flow<T>.subscribe(scope: CoroutineScope, noinline block: suspend (T) -> Unit): Job

Shortcut for chain if Flow.onEach and Flow.launchIn

Link copied to clipboard
fun <T, M> Flow<T>.subscribeAsync(scope: CoroutineScope, markerFactory: suspend (T) -> M, block: suspend (T) -> Unit): Job
Link copied to clipboard
inline fun <T> Flow<T>.subscribeSafely(scope: CoroutineScope, noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler, noinline block: suspend (T) -> Unit): Job

Use subscribe, but all blocks will be called inside of safely function. Use onException to set up your reaction for Throwables

Link copied to clipboard
inline fun <T, M> Flow<T>.subscribeSafelyAsync(scope: CoroutineScope, noinline markerFactory: suspend (T) -> M, noinline onException: ExceptionHandler<Unit> = defaultSafelyExceptionHandler, noinline block: suspend (T) -> Unit): Job
Link copied to clipboard
inline fun <T> Flow<T>.subscribeSafelySkippingExceptions(scope: CoroutineScope, noinline block: suspend (T) -> Unit): Job

Use subscribeSafelyWithoutExceptions, but all exceptions inside of safely will be skipped

Link copied to clipboard
inline fun <T, M> Flow<T>.subscribeSafelySkippingExceptionsAsync(scope: CoroutineScope, noinline markerFactory: suspend (T) -> M, noinline block: suspend (T) -> Unit): Job
Link copied to clipboard
inline fun <T> Flow<T>.subscribeSafelyWithoutExceptions(scope: CoroutineScope, noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull, noinline block: suspend (T) -> Unit): Job

Use subscribeSafelyWithoutExceptions, but all exceptions will be passed to defaultSafelyExceptionHandler

Link copied to clipboard
inline fun <T, M> Flow<T>.subscribeSafelyWithoutExceptionsAsync(scope: CoroutineScope, noinline markerFactory: suspend (T) -> M, noinline onException: ExceptionHandler<T?> = defaultSafelyWithoutExceptionHandlerWithNull, noinline block: suspend (T) -> Unit): Job
Link copied to clipboard
fun <T> Flow<T>.takeNotNull(): Flow<T & Any>
Link copied to clipboard
open override fun tryEmit(value: T): Boolean