Colton Idle
09/07/2023, 6:21 PMdoSomething() <=== Works!
bufferedReader.forEachLine {
doSomething() <=== Doesn't work (Error: "Suspension functions can be called only within coroutine body")
}
what about a bufferedReader.forEachLine kicks me out of my coroutine body...? hmJohann Pardanaud
09/07/2023, 6:24 PMforEachLine
is not an inline function, which is why the lambda is no longer executing in the coroutine scopeJohann Pardanaud
09/07/2023, 6:25 PMColton Idle
09/07/2023, 6:34 PMwhile (bufferedReader.readLine().also { currentLine = it } != null) {
and now everything works! ThanksColton Idle
09/07/2023, 6:36 PMJacob
09/07/2023, 9:11 PMaraqnid
09/08/2023, 7:32 AMaraqnid
09/08/2023, 7:34 AMfun File.lineFlow(): Flow<String> = flow {
bufferedReader().useLines { lines ->
emitAll(lines.asFlow())
}
}.flowOn(<http://Dispatchers.IO|Dispatchers.IO>)
Sam
09/08/2023, 8:04 AMforEachLine
is mentioned in the comments