sboishtyan
05/12/2021, 4:48 PMFlow
Observable.create(
{ emitter ->
val process: Process = ProcessBuilder(commandAndArgs)
.redirectErrorStream(true)
.start()
emitter.setCancellation {
process.destroy()
}
)
So idea is that I want when someone starts collecting the flow I will create a process and when a client stops collecting I will destroy the processephemient
05/12/2021, 7:39 PMchannelFlow {
val process = ...
invokeOnClose { process.destroy() }
process.inputStream.reader().useLines { lines ->
for (line in lines) send(line)
}
}
sboishtyan
05/12/2021, 8:50 PM