consoleIn

@ExperimentalCoroutinesApi
fun consoleIn(dispatcher: CoroutineDispatcher = Dispatchers.IO.limitedParallelism(1)): Flow<String>

Creates a flow of strings read from the console input (stdin) using the specified dispatcher.

Return

A flow of strings read from the console input.

Example usage:

val consoleInputFlow = consoleIn()
consoleInputFlow.collect { input -> println("You entered: $input") }

Parameters

dispatcher

The CoroutineDispatcher to use for reading from stdin. Defaults to a single-threaded dispatcher.