subIntent
open suspend fun subIntent(transformer: suspend Syntax<INTERNAL_STATE, SIDE_EFFECT>.() -> Unit)(source)
Used for parallel decomposition or subdivision of a larger intent into smaller parts.
Should only be used from within an intent or subIntent block.
An example use case for sub-intents is to launch multiple from a single intent using coroutineScope. For example, when listening to multiple flows from the OrbitContainer onCreate lambda.
override val container = scope.orbitContainer<TestState, String>(initialState) {
coroutineScope {
launch {
sendSideEffect1()
}
launch {
sendSideEffect2()
}
}
}
private suspend fun sendSideEffect1() = subIntent {
flow1.collect {
postSideEffect(it)
}
}
private suspend fun sendSideEffect1() = subIntent {
flow2.collect {
postSideEffect(it)
}
}Content copied to clipboard
Parameters
transformer
lambda representing the transformer