ResultSource

sealed interface ResultSource

Read-only source of navigation results.

The library is the only implementor: obtain a source with ResultSource.create when creating it externally (for example, in DI or a ViewModel), or from NavigationController.results. When a controller is created without an external source, it creates and owns one internally.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
inline fun <T : Any> ResultSource.consume(scope: CoroutineScope, noinline block: suspend (T) -> Unit): Job

Launches collection of results of type T in scope and passes every consumed result to block.

Link copied to clipboard
abstract fun <T : Any> observe(type: KClass<T>): Flow<Consumable<T>>

Observes results of type T, delivered after BackDestination is handled.

Link copied to clipboard
inline fun <T : Any> ResultSource.observeResults(): Flow<Consumable<T>>

Observes results of type T, delivered after BackDestination is handled. Every result is wrapped into Consumable: it is removed from the store once consumed and cannot be consumed twice.