How do I properly clean up resources when using `f...
# coroutines
d
How do I properly clean up resources when using
flow
? For example if I open an IO Stream in the
flow {}
builder, how do I clean it up? I can't use
onCompletion
, because I don't have the stream available there obviously. If I understand the docs correctly I am not supposed to use
try-finally
in the
flow {}
builder, correct?
1
f
You could use
callbackFlow
which has an
awaitClose
in its lambda scope
👍 3
d
Ah of course. I completely forgot about that one 🤦 thank you