Title: Theory / Unimportant / CS / Programming / Kotlin / Library / Flow
Tags: automatedNewLineAfterCommaSpace

Typ: Flow<T>
Meaning: A generator of value of type T for coroutines
Page: https://kotlinlang.org/docs/coroutine-context-and-dispatchers.html
Language: kotlin
Context: Coroutine

Instruction: flow {
  foo
}
Page: https://kotlinlang.org/docs/coroutine-context-and-dispatchers.html
Language: kotlin
Context: Coroutine
Returns: A flow<T> that emit some values

Instruction: emit(i)
Page: https://kotlinlang.org/docs/coroutine-context-and-dispatchers.html
Effect: the flow outputs i
Language: kotlin
Context: Coroutine
Where to use it: in a flow/flowCollector

Name: A cold stream
Definition: A stream that generates its value on demand
Page: https://kotlinlang.org/docs/coroutine-context-and-dispatchers.html
Context: Kotlin
Example: flow

Instruction: emitAll(emmitter)
Page: https://kotlinlang.org/docs/coroutine-context-and-dispatchers.html
Effect: consume and emit all elements of emmitter
Language: kotlin
Context: Coroutine
Variables: emmitter: ReceiveChannel or Flow
Where to use it: in a flow/flowCollector

Typ: MutableSharedFlow<T>
Meaning: mutable SharedFlow that provides functions to emit values to the flow.
Page: https://kotlinlang.org/docs/coroutine-context-and-dispatchers.html
Language: kotlin
Chapter: in a flow/flowCollector
Context: Coroutine
Subtype of: SharedFlow<T>, FlowCollector<T>

Instruction: tryEmit(value)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-mutable-shared-flow/index.html
Effect: try to emit value immediately. Don't block
Language: kotlin
Context: Coroutine
Returns: whether the value was emitted
Where to use it: MutableSharedFlow<T>

Variable: sharedFlow.subscriptionCount
Meaning: The number of subscribers (active collectors) to this shared flow.
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-mutable-shared-flow/index.html
Context: Coroutine
Language: kotlin
Variables: MutableSharedFlow<T> sharedFlow

Instruction: sharedFlow.asSharedFlow()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-mutable-shared-flow/index.html
Language: kotlin
Context: Coroutine
Returns: This flow, as a SharedFlow (non mutable)
Variables: MutableSharedFlow<T> sharedFlow

Typ: SharedFlow<out T>
Meaning: A hotFlow that shares emitted values among all its collectors in a broadcast fashion
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-shared-flow/index.html
Language: kotlin
Context: Coroutine
Subtype of: Flow<T>

Name: A subscriber of sharedFlow
Definition: An object that gets values emitted by sharedFlow
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-shared-flow/index.html
Variables: SharedFlow<out T> sharedFlow
Context: Kotlin

Name: The replay cache
Definition: A list of some of the values recently emitted
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-shared-flow/index.html
Variables: SharedFlow<out T> sharedFlow
Context: Kotlin

Question: What is the point of replay cache
Answer: Last emitted values are sent to a new subscriber
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-shared-flow/index.html
Variables: SharedFlow<out T> sharedFlow
Context: Kotlin
Answer2: If a subscriber can't accept value, it can read them later from replay cache

Instruction: flow.collect(flowCollector)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-shared-flow/index.html
Effect: Accepts the given collector and emits values into it.
Language: Kotlin
Variables: SharedFlow<out T>| AbstractFlow<T> flow

Variable: sharedFlow.replayCache
Meaning: List of values recently emitted
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-shared-flow/index.html
Language: Kotlin
Variables: SharedFlow<out T> sharedFlow

Instruction: sharedFlow.onSubscription(action)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-shared-flow/index.html
Language: Kotlin
Returns: a flow that invokes the given action after this shared flow starts to be collected (after the subscription is registered).
Variables: SharedFlow<out T> sharedFlow

Typ: StateFlow<out T>
Meaning: A SharedFlow that represents a read-only state with a single updatable data value that emits updates to the value to its collectors.
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-shared-flow/index.html
Language: Kotlin
Subtype of: SharedFlow<T>

Variable: stateFlow.value
Meaning: The current value of the state flow
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/index.html
Language: Kotlin
Typ: StateFlow<out T> stateFlow

Typ: MutableStateFlow<T>
Meaning: A mutable StateFlow that provides a setter for value.
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-mutable-state-flow/index.html
Language: Kotlin
Subtype of: StateFlow<T> , MutableSharedFlow<T>

Instruction: mutableStateFlow.compareAndSet(
  expect,
  update
)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-mutable-state-flow/index.html
Effect: Atomically compares the current value with expect and sets it to update if it is equal to expect.
Language: Kotlin
Returns: whether value is set to update
Variables: MutableStateFlow<T> mutableStateFlow

Instruction: mutableStateFlow.asStateFlow()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-mutable-state-flow/index.html
Language: Kotlin
Returns: Current stateFlow, seen as a stateFlow (non mutable)
Variables: MutableStateFlow<T> mutableStateFlow

Typ: AbstractFlow<T>
Meaning: Base class for stateful implementations of Flow.
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-abstract-flow/index.html
Language: Kotlin
Subtype of: Flow<T> , CancellableFlow<T>

Instruction: flow.collectSafely(flowCollector)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-abstract-flow/index.html
Effect: Accepts the given collector and emits values into it, don't change context when emitting value, emission happen in the context of the collect call, and emit are serialized
Language: Kotlin
Variables: AbstractFlow<T> flow

Instruction: x.asFlow()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/as-flow.html
Language: Kotlin
Returns: same collection of element as in x, but returned as a cold flow

Instruction: flow.buffer(
  capacity = BUFFERED,
  bufferOverflow = BufferOverflow.SUSPEND
)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/as-flow.html
Language: Kotlin
Returns: Uses flow as a hot flow in a different coroutine, and return it as a cold flow.
This buffer contains at most capacity element that were received and not emitted. If the flow go over capacity, it behaves as indicated in bufferOverflow
Variables: Flow<T> flow

Typ: BufferOverflow
TypMeaning: A strategy for buffer overflow handling in channels and flows that controls what is going to be sacrificed on buffer overflow:
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-buffer-overflow/index.html
Language: Kotlin
Value: SUSPEND — the upstream that is sending or is emitting a value is suspended while the buffer is full.
Value2: DROP_OLDEST — drop the oldest value in the buffer on overflow, add the new value to the buffer, do not suspend.
Value3: DROP_LATEST — drop the latest value that is being added to the buffer right now on buffer overflow (so that buffer contents stay the same), do not suspend.

Constant: BUFFERED
Meaning: Requests a buffered channel with the default buffer capacity in the Channel(...) factory function.
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-buffer-overflow/index.html
Language: Kotlin
Typ: BufferOverflow

Constant: CONFLATED
Meaning: Requests a conflated channel in the Channel(...) factory function. This is a shortcut to creating a channel with onBufferOverflow = DROP_OLDEST.
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-buffer-overflow/index.html
Language: Kotlin
Typ: BufferOverflow

Constant: UNLIMITED
Meaning: Requests a channel with an unlimited capacity buffer in the Channel(...) factory function.
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-buffer-overflow/index.html
Language: Kotlin
Typ: BufferOverflow

Instruction: flow.callbackFlow(block)
flow.channelFlow(block)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/callback-flow.html
Language: Kotlin
Returns: A cold flow, with same element as flow, that call block.send(value) for every value emitted.
Variables: Flow flow

Instruction: flow.cancellable()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/callback-flow.html
Language: Kotlin
Returns: flow and also throws cancellation on each emission if the coroutine is cancelled
Variables: Flow flow

Instruction: flow.catch(action)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/callback-flow.html
Language: Kotlin
Returns: The flow flow, up until it it throws exception, then action(exception)
Variables: Flow flow

Instruction: flow.collect()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/callback-flow.html
Effect: Terminal flow operator that collects the given flow but ignores all emitted values.
Language: Kotlin
Variables: Flow flow
Exception: exception thrown by the flow

Instruction: flow.collectIndexed(action)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/callback-flow.html
Effect: call action(index, value) for each value emitted by the flow
Language: Kotlin
Variables: Flow flow
Exception: exception thrown by the flow

Instruction: flow.collectLatest(action)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/callback-flow.html
Effect: Call action on each value emitted by flow. Immediattely request another value. When the next value arrive, cancel current action.
Language: Kotlin
Variables: Flow flow

Instruction: flow1.combine(
  flow2,
  transform
)
Flow.combine(
  flow1,
  flow2,
  transform
)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/callback-flow.html
Language: Kotlin
Returns: A flow, that emits
transform(  value1, value2)
for the last value1 and value2 emitted, and each time a new value is emitted
Variables: Flow flow1,
  flow2

Instruction: flow1.combineTransform(
  flow2,
  transform
)
Flow.combineTransform(
  flow1,
  flow2,
  transform
)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/callback-flow.html
Language: Kotlin
Returns: The flow, generated by transform(  value1, value2) each time flow1 or flow2 emit a new value
Variables: Flow flow1,
  flow2

Instruction: flow.conflate()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/callback-flow.html
Language: Kotlin
Returns: A flow that emits the last value emitted by flow, treated as a hot flow
Variables: Flow flow

Instruction: receiveChannel.consumeAsFlow()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: the given receive channel as a hot flow and consumes the channel on the first collection from this flow.
Variables: ReceiveChannel<T> receiveChannel
Assuming: can be collected just once and throws IllegalStateException when trying to collect it more than once.

Instruction: flow.count()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: the number of elements in this flow.
Variables: Flow<T> flow

Instruction: flow.count(predicate)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: the number of elements in this flow matching the given predicate
Variables: Flow<T> flow

Instruction: flow.debounce(
timeoutMillis: Long
)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: A flow that mirrors the original flow, but filters out values that are followed by the newer values within the given timeout.
Variables: Flow<T> flow

Instruction: flow.debounce(timeoutMillis: (T) ->Long)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: A flow that mirrors the original flow, but filters out values that are followed by the newer values within timeoutMillis(value)
Variables: Flow<T> flow

Instruction: flow.distinctUntilChanged()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: A flow, same as flow, but only emitting distinct values
Variables: Flow<T> flow

Instruction: flow.distinctUntilChanged(areEquivalent)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: A flow, same as flow, but only emitting distinct values according to areEquivalent(oldValue, newValue)
Variables: Flow<T> flow

Instruction: flow.distinctUntilChangedBy(keySelector: (T) -> K)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: A flow, same as flow, but only emitting distinct values according to keySelector(oldValue) and keySelector(newValue)
Variables: Flow<T> flow

Instruction: flow.drop(count)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: a flow that ignores first count elements.
Variables: Flow<T> flow

Instruction: flow.dropWhile(predicate)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: a flow that drop all of the first elements satisfying predicate
Variables: Flow<T> flow

Instruction: flowCollector.emitAll(channel)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Effect: Emits all elements from the given channel to this flow collector and cancels (consumes) the channel afterwards.
Language: Kotlin
Variables: FlowCollector<T> flowCollector

Instruction: emptyFlow()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: An empty flow

Instruction: flow.filter(predicate)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: a flow containing only values of the original flow that match the given predicate.
Variables: Flow<T> flow

Instruction: flow.filterIsInstance<R>()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: a flow containing only values that are instance of R
Variables: Flow<T> flow

Instruction: flow.filterNot(predicate)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: a flow containing only values that do not match predicate
Variables: Flow<T> flow

Instruction: flow.filterNotNull()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: A Flow<T> that emit same values as flow except for null value
Variables: Flow<T?> flow

Instruction: flow.first()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Effect: Cancel the flow after the first element
Language: Kotlin
Returns: First element of the flow
Variables: Flow<T?> flow

Instruction: flow.first(predicate)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Effect: Cancel the flow after the first element satisfying predicate
Language: Kotlin
Returns: First element of the flow satisfying predicate
Variables: Flow<T?> flow

Instruction: flow.firstOrNull(predicate)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Effect: Cancel the flow after the first element satisfying predicate
Language: Kotlin
Returns: First element of the flow satisfying predicate, or null if none exists
Variables: Flow<T?> flow

Instruction: flow.firstOrNull()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Effect: Cancel the flow after the first element
Language: Kotlin
Returns: First element of the flow, or null if its empty
Variables: Flow<T> flow

Instruction: flow.flatMapConcat(transform: suspend (T) -> Flow<R>)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: A flow that emits every element emitted by transform(value) for each value emitted by flow
Variables: Flow<T> flow

Instruction: flow.flatMapLatest(transform: suspend (T) -> Flow<R>)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: A flow that emits every element emitted by transform(value) for each value emitted by flow considered as a hot flow, cancelling preceding transform result one a new value is emitted by flow
Variables: Flow<T> flow

Instruction: flow.flattenConcat()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: For each inner_flow emitted by flow
emit the value emitted of inner_flow
Variables: Flow<Flow<T>> flow

Instruction: flow.flattenMerge(concurrency)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Language: Kotlin
Returns: Emits elements emitted by inner_flow emitted by flow, considering concurrency inner_flows at a single time
Variables: Flow<Flow<T>> flow

Name: An intermediate operator
Definition: A flow method that returns a flow
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Context: Flow kotiln

Name: A terminal operator
Definition: A flow method that collect the flow and don't return a flow
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/consume-as-flow.html
Context: Flow kotiln

Instruction: flow(block)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: a cold flow from the given suspendable block. Calling block everytime a terminal operator is applied to resulting fllow

Instruction: flowOf(
  elt_1,
  ...,
  elt_n
)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: a flow emitting elt_1, ... and elt_n

Instruction: flowOn(context)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: same flow but executed in context

Instruction: flow.fold(
  initial,
  operation
)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: (  ...(  initial operation value_1) operation value_2 operation .... operation value_n), for value_1, .., value_n the values emitted by flow
Variables: Flow flow

Instruction: flow.last()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: The last element of the show
Variables: Flow flow
Exception: NoSuchElementException if the flow was empty.

Instruction: flow.lastOrNull()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: The last element of the show, or null if it was empty
Variables: Flow flow

Instruction: flow.launchIn(scope)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: Terminal flow operator that launches the collection of the given flow in the scope.
Variables: Flow flow

Instruction: flow.map(transform)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: Flow emitting transform(value) for each value emitted by transform
Variables: Flow flow

Instruction: flow.mapLatest(transform)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: todo when not experimental
Variables: Flow flow

Instruction: flow.mapNotNull(transform)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: Flow that contains non-null result of transform(value) for value emitted by flow
Variables: Flow flow

Instruction: flows.merge()
merge(flows)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: emit all values emitted by inner_flow of flows, in whatever order they are emitted by inner_flows
Variables: Flow flow

Instruction: flow.onCompletion(action)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: flow same as flow, followed by action(cause), with cause the exception causing the end, or null otherwise
Variables: Flow flow

Instruction: flow.onEach(action)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: a flow that invokes the given action before each value of the upstream flow is emitted downstream.
Variables: Flow flow

Instruction: flow.onEmpty(action)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: if flow is empty, then action(), otherwise flow
Variables: Flow flow

Instruction: flow.onStart(action)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: the flow action() first then flow
Variables: Flow flow

Instruction: flow.reduce(operation)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: (....(value1 operation value_2) ... operation value_n), with value_1 ... value_n emitted by flow
Variables: Flow flow
Exception: NoSuchElementException if flow was empty.

Instruction: flow.retry(
  retries,
  predicate
)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Effect: Retries collection of the given flow up to retries times when an exception that matches the given predicate occurs in the upstream flow.
Language: Kotlin
Context: flow
Variables: Flow flow

Instruction: flow.retryWhen(predicate)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Effect: Retries collection of the given flow when an exception occurs in the upstream flow and the predicate returns true.
Language: Kotlin
Context: flow
Variables: Flow flow

Instruction: flow.runningFold(
  initial,
  operation
)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Effect: (...(initial operation value_1) operation ... operation value_n) for value_1, ..., value_n emitted by flow
Language: Kotlin
Context: flow
Variables: Flow flow

Instruction: flow.runningReduce(operation)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: the flow that returns
[value_1,
(value_1 operation value_2,
...
(....(value1 operation value_2) ... operation value_n)]
with value_1 ... value_n emitted
Variables: Flow flow

Instruction: flow.sample(periodMillis)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: a flow that emits only the latest value emitted by the original flow during the given sampling period.
Variables: Flow flow

Instruction: flow.scan(
  initial,
  operation
)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: the flow that returns
[initial,
(  initial operation value_1),
(  (  initial operation value_1) operation value_2),
...
(  ....(  (  initial operation value_1) operation value_2) ... operation value_n)]
with value_1 ... value_n emitted
Variables: Flow flow

Instruction: flow.shareIn(
  scope,
  started,
  replay
)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: Converts a coldFlow into a hotSharedFlow that is started in the given coroutine scope, sharing emissions from a single running instance of the upstream flow with multiple downstream subscribers, and replaying a specified number of replay values to new subscribers.
TODO
Variables: Flow flow

Typ: flow.sharingCommand
TypMeaning: A command emitted by SharingStarted implementations to control the sharing coroutine in the shareIn and stateIn operators.
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Value: STOP_AND_RESET_REPLAY_CACHE()
Stops sharing, cancelling collection of the upstream flow, and resets the SharedFlow.replayCache to its initial state. The shareIn operator calls MutableSharedFlow.resetReplayCache; the stateIn operator resets the value to its original initialValue.
Value2: STOP()
Stops sharing, cancelling collection of the upstream flow.
Value3: START()
Starts sharing, launching collection of the upstream flow.

Instruction: flow.single()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: the single value emitted by flow
Variables: Flow flow
Exception: Throws NoSuchElementException for empty flow and IllegalStateException for flow that contains more than one element.

Instruction: flow.singleOrNull()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: the single value emitted by flow, or null if there are 0 or many values emitted
Variables: Flow flow

Instruction: flow.stateIn(
  scope,
  started
)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: Converts a coldFlow into a hotStateFlow that is started in the given coroutine scope, sharing the most recently emitted value from a single running instance of the upstream flow with multiple downstream subscribers.
todo
Variables: Flow flow

Instruction: flow.take(count)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: A flow that returns only the first count values
Variables: Flow flow

Instruction: flow.takeWhile(predicate)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: A flow that returns values while predicate holds, then halt
Variables: Flow flow

Instruction: flow.toCollection(destination)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: add element emitted by flow to the destination
Variables: Flow flow

Instruction: flow.toList(destination = ArrayList())
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: The list of elements returned by flow. New list or destination
Variables: Flow flow

Instruction: flow.toSet(
destination = LinkedHashSet()
)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: The set of elements returned by flow. New set or destination
Variables: Flow flow

Instruction: flow.transform(transform)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: the flow emitted by transform(value) for each value emitted by flow
Variables: Flow flow

Instruction: flow.transformLatest(transform)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: the flow emitted by transform(value) for each value emitted by flow, cancel transform when flow emits a new value
Variables: Flow flow

Instruction: flow.transformWhile(transform)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: Applies transform function to each value of the given flow while this function returns true.
Variables: Flow flow

Instruction: flow.withIndex()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: Same flow, but values are indexed
Variables: Flow flow

Instruction: flow_a.zip(
  flow_b,
  transform
)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: The flow emitting transform(  value_a, value_b) for the i-th value_a, value_b emitted by flow_a, flow_b
Variables: Flow flow

Instruction: mutableStateflow.getAndUpdate(function)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Effect: Updates the MutableStateFlow.value atomically using the specified function of its value, and returns its prior value.
function may be evaluated multiple times, if value is being concurrently updated.
Language: Kotlin
Context: flow
Variables: MutableStateFlow mutableStateflow

Instruction: mutableStateflow.update(function)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Effect: Updates the MutableStateFlow.value atomically using the specified function of its value.
function may be evaluated multiple times, if value is being concurrently updated.
Language: Kotlin
Context: flow
Variables: MutableStateFlow mutableStateflow

Instruction: mutableStateflow.updateAndGet(function)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Effect: Updates the MutableStateFlow.value atomically using the specified function of its value
function may be evaluated multiple times, if value is being concurrently updated.
Language: Kotlin
Context: flow
Returns: the new value.
Variables: MutableStateFlow mutableStateflow

Instruction: SharingStarted.Companion.WhileSubscribed(
  stopTimeout: Duration = Duration.ZERO,
  replayExpiration: Duration = Duration.INFINITE
): SharingStarted
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Effect: Sharing is started when the first subscriber appears, immediately stops when the last subscriber disappears (by default), keeping the replay cache forever (by default).
It has the following optional parameters:
stopTimeout — configures a delay between the disappearance of the last subscriber and the stopping of the sharing coroutine. It defaults to zero (stop immediately).
replayExpiration — configures a delay between the stopping of the sharing coroutine and the resetting of the replay cache (which makes the cache empty for the shareIn operator and resets the cached value to the original initialValue for the stateIn operator). It defaults to Duration.INFINITE (keep replay cache forever, never reset buffer). Use Duration.ZERO value to expire the cache immediately.
This function throws IllegalArgumentException when either stopTimeout or replayExpiration are negative.
Language: Kotlin
Context: flow
Returns: the new value.

Instruction: sharedFlow.onSubscription(action)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: A shared flow that emit action after the flow starts to be collected
Variables: SharedFlow sharedFlow

Instruction: flow.produceIn(scope)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: Creates a produce coroutine that collects the given flow.
This transformation is stateful, it launches a produce coroutine that collects the given flow, and has the same behavior:
if collecting the flow throws, the channel will be closed with that exception
if the ReceiveChannel is cancelled, the collection of the flow will be cancelled
if collecting the flow completes normally, the ReceiveChannel will be closed normally
A channel with default buffer size is created. Use buffer operator on the flow before calling produceIn to specify a value other than default and to control what happens when data is produced faster than it is consumed, that is to control backpressure behavior.
Variables: Flow flow
Typ: ReceiveChannel<T>

Instruction: receiveChannel.receiveAsFlow()
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: The given receive channel as a hot flow and receives from the channel in fan-out fashion every time this flow is collected.
Variables: ReceiveChannel<T> receiveChannel
Extra: - Flow collectors are cancelled when the original channel is closed with an exception.
- Flow collectors complete normally when the original channel is closed normally.
- Failure or cancellation of the flow collector does not affect the channel.

Typ: SharingStarted
Meaning: A strategy for starting and stopping the sharing coroutine in shareIn and stateIn operators.
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow

Instruction: flow.flatMapMerge(
  concurrency,
  transform
)
Page: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.htm
Language: Kotlin
Context: flow
Returns: The flows transform(  value) for value in flow
Variables: Flow flow