combineStates

fun <T1, T2, R> combineStates(flow1: StateFlow<T1>, flow2: StateFlow<T2>, transform: (T1, T2) -> R): StateFlow<R>(source)

Returns a read-only StateFlow derived from two source state flows using transform.

Every access to StateFlow.value reads each source's current value separately and invokes transform once. Each individual read is thread-safe, but reading several independent state flows is not one atomic operation. If a source changes while the values are being read, transform can receive values observed at different moments that might not have existed together. The transformed result is not cached between property reads. Every access to StateFlow.replayCache performs the same fresh computation and returns the result as a singleton list.

Each collector independently invokes transform for combined source values observed by that collector. Collection follows StateFlow's strong equality-based conflation: a slow collector can skip intermediate transformed values, and a transformed value that is equal to the last emitted value is not emitted again. Property reads and collectors do not share transformed results. Updating a source invokes transform only when the returned state flow is being collected; otherwise transformation occurs only when StateFlow.value or StateFlow.replayCache is accessed.

transform can be invoked repeatedly and concurrently. To preserve StateFlow semantics, it must be deterministic, side-effect-free, safe for concurrent invocation, and must not throw. An exception from transform escapes the property access or fails the affected collection; it is not represented as a state value.

This operator is useful when a StateFlow result is required instead of the Flow returned by combine.

See also


fun <T1, T2, T3, R> combineStates(flow1: StateFlow<T1>, flow2: StateFlow<T2>, flow3: StateFlow<T3>, transform: (T1, T2, T3) -> R): StateFlow<R>(source)

Returns a read-only StateFlow derived from three source state flows using transform.

Every access to StateFlow.value reads each source's current value separately and invokes transform once. Each individual read is thread-safe, but reading several independent state flows is not one atomic operation. If a source changes while the values are being read, transform can receive values observed at different moments that might not have existed together. The transformed result is not cached between property reads. Every access to StateFlow.replayCache performs the same fresh computation and returns the result as a singleton list.

Each collector independently invokes transform for combined source values observed by that collector. Collection follows StateFlow's strong equality-based conflation: a slow collector can skip intermediate transformed values, and a transformed value that is equal to the last emitted value is not emitted again. Property reads and collectors do not share transformed results. Updating a source invokes transform only when the returned state flow is being collected; otherwise transformation occurs only when StateFlow.value or StateFlow.replayCache is accessed.

transform can be invoked repeatedly and concurrently. To preserve StateFlow semantics, it must be deterministic, side-effect-free, safe for concurrent invocation, and must not throw. An exception from transform escapes the property access or fails the affected collection; it is not represented as a state value.

This operator is useful when a StateFlow result is required instead of the Flow returned by combine.

See also


fun <T1, T2, T3, T4, R> combineStates(flow1: StateFlow<T1>, flow2: StateFlow<T2>, flow3: StateFlow<T3>, flow4: StateFlow<T4>, transform: (T1, T2, T3, T4) -> R): StateFlow<R>(source)

Returns a read-only StateFlow derived from four source state flows using transform.

Every access to StateFlow.value reads each source's current value separately and invokes transform once. Each individual read is thread-safe, but reading several independent state flows is not one atomic operation. If a source changes while the values are being read, transform can receive values observed at different moments that might not have existed together. The transformed result is not cached between property reads. Every access to StateFlow.replayCache performs the same fresh computation and returns the result as a singleton list.

Each collector independently invokes transform for combined source values observed by that collector. Collection follows StateFlow's strong equality-based conflation: a slow collector can skip intermediate transformed values, and a transformed value that is equal to the last emitted value is not emitted again. Property reads and collectors do not share transformed results. Updating a source invokes transform only when the returned state flow is being collected; otherwise transformation occurs only when StateFlow.value or StateFlow.replayCache is accessed.

transform can be invoked repeatedly and concurrently. To preserve StateFlow semantics, it must be deterministic, side-effect-free, safe for concurrent invocation, and must not throw. An exception from transform escapes the property access or fails the affected collection; it is not represented as a state value.

This operator is useful when a StateFlow result is required instead of the Flow returned by combine.

See also


fun <T1, T2, T3, T4, T5, R> combineStates(flow1: StateFlow<T1>, flow2: StateFlow<T2>, flow3: StateFlow<T3>, flow4: StateFlow<T4>, flow5: StateFlow<T5>, transform: (T1, T2, T3, T4, T5) -> R): StateFlow<R>(source)

Returns a read-only StateFlow derived from five source state flows using transform.

Every access to StateFlow.value reads each source's current value separately and invokes transform once. Each individual read is thread-safe, but reading several independent state flows is not one atomic operation. If a source changes while the values are being read, transform can receive values observed at different moments that might not have existed together. The transformed result is not cached between property reads. Every access to StateFlow.replayCache performs the same fresh computation and returns the result as a singleton list.

Each collector independently invokes transform for combined source values observed by that collector. Collection follows StateFlow's strong equality-based conflation: a slow collector can skip intermediate transformed values, and a transformed value that is equal to the last emitted value is not emitted again. Property reads and collectors do not share transformed results. Updating a source invokes transform only when the returned state flow is being collected; otherwise transformation occurs only when StateFlow.value or StateFlow.replayCache is accessed.

transform can be invoked repeatedly and concurrently. To preserve StateFlow semantics, it must be deterministic, side-effect-free, safe for concurrent invocation, and must not throw. An exception from transform escapes the property access or fails the affected collection; it is not represented as a state value.

This operator is useful when a StateFlow result is required instead of the Flow returned by combine.

See also


fun <T1, T2, T3, T4, T5, T6, R> combineStates(flow1: StateFlow<T1>, flow2: StateFlow<T2>, flow3: StateFlow<T3>, flow4: StateFlow<T4>, flow5: StateFlow<T5>, flow6: StateFlow<T6>, transform: (T1, T2, T3, T4, T5, T6) -> R): StateFlow<R>(source)

Returns a read-only StateFlow derived from six source state flows using transform.

Every access to StateFlow.value reads each source's current value separately and invokes transform once. Each individual read is thread-safe, but reading several independent state flows is not one atomic operation. If a source changes while the values are being read, transform can receive values observed at different moments that might not have existed together. The transformed result is not cached between property reads. Every access to StateFlow.replayCache performs the same fresh computation and returns the result as a singleton list.

Each collector independently invokes transform for combined source values observed by that collector. Collection follows StateFlow's strong equality-based conflation: a slow collector can skip intermediate transformed values, and a transformed value that is equal to the last emitted value is not emitted again. Property reads and collectors do not share transformed results. Updating a source invokes transform only when the returned state flow is being collected; otherwise transformation occurs only when StateFlow.value or StateFlow.replayCache is accessed.

transform can be invoked repeatedly and concurrently. To preserve StateFlow semantics, it must be deterministic, side-effect-free, safe for concurrent invocation, and must not throw. An exception from transform escapes the property access or fails the affected collection; it is not represented as a state value.

This operator is useful when a StateFlow result is required instead of the Flow returned by combine.

See also


fun <T1, T2, T3, T4, T5, T6, T7, R> combineStates(flow1: StateFlow<T1>, flow2: StateFlow<T2>, flow3: StateFlow<T3>, flow4: StateFlow<T4>, flow5: StateFlow<T5>, flow6: StateFlow<T6>, flow7: StateFlow<T7>, transform: (T1, T2, T3, T4, T5, T6, T7) -> R): StateFlow<R>(source)

Returns a read-only StateFlow derived from seven source state flows using transform.

Every access to StateFlow.value reads each source's current value separately and invokes transform once. Each individual read is thread-safe, but reading several independent state flows is not one atomic operation. If a source changes while the values are being read, transform can receive values observed at different moments that might not have existed together. The transformed result is not cached between property reads. Every access to StateFlow.replayCache performs the same fresh computation and returns the result as a singleton list.

Each collector independently invokes transform for combined source values observed by that collector. Collection follows StateFlow's strong equality-based conflation: a slow collector can skip intermediate transformed values, and a transformed value that is equal to the last emitted value is not emitted again. Property reads and collectors do not share transformed results. Updating a source invokes transform only when the returned state flow is being collected; otherwise transformation occurs only when StateFlow.value or StateFlow.replayCache is accessed.

transform can be invoked repeatedly and concurrently. To preserve StateFlow semantics, it must be deterministic, side-effect-free, safe for concurrent invocation, and must not throw. An exception from transform escapes the property access or fails the affected collection; it is not represented as a state value.

This operator is useful when a StateFlow result is required instead of the Flow returned by combine.

See also


fun <T1, T2, T3, T4, T5, T6, T7, T8, R> combineStates(flow1: StateFlow<T1>, flow2: StateFlow<T2>, flow3: StateFlow<T3>, flow4: StateFlow<T4>, flow5: StateFlow<T5>, flow6: StateFlow<T6>, flow7: StateFlow<T7>, flow8: StateFlow<T8>, transform: (T1, T2, T3, T4, T5, T6, T7, T8) -> R): StateFlow<R>(source)

Returns a read-only StateFlow derived from eight source state flows using transform.

Every access to StateFlow.value reads each source's current value separately and invokes transform once. Each individual read is thread-safe, but reading several independent state flows is not one atomic operation. If a source changes while the values are being read, transform can receive values observed at different moments that might not have existed together. The transformed result is not cached between property reads. Every access to StateFlow.replayCache performs the same fresh computation and returns the result as a singleton list.

Each collector independently invokes transform for combined source values observed by that collector. Collection follows StateFlow's strong equality-based conflation: a slow collector can skip intermediate transformed values, and a transformed value that is equal to the last emitted value is not emitted again. Property reads and collectors do not share transformed results. Updating a source invokes transform only when the returned state flow is being collected; otherwise transformation occurs only when StateFlow.value or StateFlow.replayCache is accessed.

transform can be invoked repeatedly and concurrently. To preserve StateFlow semantics, it must be deterministic, side-effect-free, safe for concurrent invocation, and must not throw. An exception from transform escapes the property access or fails the affected collection; it is not represented as a state value.

This operator is useful when a StateFlow result is required instead of the Flow returned by combine.

See also


fun <T1, T2, T3, T4, T5, T6, T7, T8, T9, R> combineStates(flow1: StateFlow<T1>, flow2: StateFlow<T2>, flow3: StateFlow<T3>, flow4: StateFlow<T4>, flow5: StateFlow<T5>, flow6: StateFlow<T6>, flow7: StateFlow<T7>, flow8: StateFlow<T8>, flow9: StateFlow<T9>, transform: (T1, T2, T3, T4, T5, T6, T7, T8, T9) -> R): StateFlow<R>(source)

Returns a read-only StateFlow derived from nine source state flows using transform.

Every access to StateFlow.value reads each source's current value separately and invokes transform once. Each individual read is thread-safe, but reading several independent state flows is not one atomic operation. If a source changes while the values are being read, transform can receive values observed at different moments that might not have existed together. The transformed result is not cached between property reads. Every access to StateFlow.replayCache performs the same fresh computation and returns the result as a singleton list.

Each collector independently invokes transform for combined source values observed by that collector. Collection follows StateFlow's strong equality-based conflation: a slow collector can skip intermediate transformed values, and a transformed value that is equal to the last emitted value is not emitted again. Property reads and collectors do not share transformed results. Updating a source invokes transform only when the returned state flow is being collected; otherwise transformation occurs only when StateFlow.value or StateFlow.replayCache is accessed.

transform can be invoked repeatedly and concurrently. To preserve StateFlow semantics, it must be deterministic, side-effect-free, safe for concurrent invocation, and must not throw. An exception from transform escapes the property access or fails the affected collection; it is not represented as a state value.

This operator is useful when a StateFlow result is required instead of the Flow returned by combine.

See also


fun <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, R> combineStates(flow1: StateFlow<T1>, flow2: StateFlow<T2>, flow3: StateFlow<T3>, flow4: StateFlow<T4>, flow5: StateFlow<T5>, flow6: StateFlow<T6>, flow7: StateFlow<T7>, flow8: StateFlow<T8>, flow9: StateFlow<T9>, flow10: StateFlow<T10>, transform: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) -> R): StateFlow<R>(source)

Returns a read-only StateFlow derived from ten source state flows using transform.

Every access to StateFlow.value reads each source's current value separately and invokes transform once. Each individual read is thread-safe, but reading several independent state flows is not one atomic operation. If a source changes while the values are being read, transform can receive values observed at different moments that might not have existed together. The transformed result is not cached between property reads. Every access to StateFlow.replayCache performs the same fresh computation and returns the result as a singleton list.

Each collector independently invokes transform for combined source values observed by that collector. Collection follows StateFlow's strong equality-based conflation: a slow collector can skip intermediate transformed values, and a transformed value that is equal to the last emitted value is not emitted again. Property reads and collectors do not share transformed results. Updating a source invokes transform only when the returned state flow is being collected; otherwise transformation occurs only when StateFlow.value or StateFlow.replayCache is accessed.

transform can be invoked repeatedly and concurrently. To preserve StateFlow semantics, it must be deterministic, side-effect-free, safe for concurrent invocation, and must not throw. An exception from transform escapes the property access or fails the affected collection; it is not represented as a state value.

This operator is useful when a StateFlow result is required instead of the Flow returned by combine.

See also


fun <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, R> combineStates(flow1: StateFlow<T1>, flow2: StateFlow<T2>, flow3: StateFlow<T3>, flow4: StateFlow<T4>, flow5: StateFlow<T5>, flow6: StateFlow<T6>, flow7: StateFlow<T7>, flow8: StateFlow<T8>, flow9: StateFlow<T9>, flow10: StateFlow<T10>, flow11: StateFlow<T11>, transform: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) -> R): StateFlow<R>(source)

Returns a read-only StateFlow derived from eleven source state flows using transform.

Every access to StateFlow.value reads each source's current value separately and invokes transform once. Each individual read is thread-safe, but reading several independent state flows is not one atomic operation. If a source changes while the values are being read, transform can receive values observed at different moments that might not have existed together. The transformed result is not cached between property reads. Every access to StateFlow.replayCache performs the same fresh computation and returns the result as a singleton list.

Each collector independently invokes transform for combined source values observed by that collector. Collection follows StateFlow's strong equality-based conflation: a slow collector can skip intermediate transformed values, and a transformed value that is equal to the last emitted value is not emitted again. Property reads and collectors do not share transformed results. Updating a source invokes transform only when the returned state flow is being collected; otherwise transformation occurs only when StateFlow.value or StateFlow.replayCache is accessed.

transform can be invoked repeatedly and concurrently. To preserve StateFlow semantics, it must be deterministic, side-effect-free, safe for concurrent invocation, and must not throw. An exception from transform escapes the property access or fails the affected collection; it is not represented as a state value.

This operator is useful when a StateFlow result is required instead of the Flow returned by combine.

See also


fun <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, R> combineStates(flow1: StateFlow<T1>, flow2: StateFlow<T2>, flow3: StateFlow<T3>, flow4: StateFlow<T4>, flow5: StateFlow<T5>, flow6: StateFlow<T6>, flow7: StateFlow<T7>, flow8: StateFlow<T8>, flow9: StateFlow<T9>, flow10: StateFlow<T10>, flow11: StateFlow<T11>, flow12: StateFlow<T12>, transform: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) -> R): StateFlow<R>(source)

Returns a read-only StateFlow derived from twelve source state flows using transform.

Every access to StateFlow.value reads each source's current value separately and invokes transform once. Each individual read is thread-safe, but reading several independent state flows is not one atomic operation. If a source changes while the values are being read, transform can receive values observed at different moments that might not have existed together. The transformed result is not cached between property reads. Every access to StateFlow.replayCache performs the same fresh computation and returns the result as a singleton list.

Each collector independently invokes transform for combined source values observed by that collector. Collection follows StateFlow's strong equality-based conflation: a slow collector can skip intermediate transformed values, and a transformed value that is equal to the last emitted value is not emitted again. Property reads and collectors do not share transformed results. Updating a source invokes transform only when the returned state flow is being collected; otherwise transformation occurs only when StateFlow.value or StateFlow.replayCache is accessed.

transform can be invoked repeatedly and concurrently. To preserve StateFlow semantics, it must be deterministic, side-effect-free, safe for concurrent invocation, and must not throw. An exception from transform escapes the property access or fails the affected collection; it is not represented as a state value.

This operator is useful when a StateFlow result is required instead of the Flow returned by combine.

See also