You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a kotlin developer familiar with kotlin coroutines and Flow, which is direct mapping to async/await + AsyncSequence.
The most powerful thing that kotlin flow has is the builder, which allows you to emit values arbitrarily and use all the async stuff since the closure is async, like so (I'll write it in async/await syntax so you understand better)
flow { emitter in
await emitter.emit(1)
await Task.sleep(1_000)
await emitter.emit(10)
await Task.sleep(1_000)
for 0...10 {
await emitter.emit(100)
}
}
when the closure returns, the flow terminates, if you throw inside the closure, then error is propagated as usual
It allow you to then create arbitrary custom operators, or simply way to pipe async function into AsyncSequence like
I'm a kotlin developer familiar with kotlin coroutines and Flow, which is direct mapping to async/await + AsyncSequence.
The most powerful thing that kotlin flow has is the builder, which allows you to emit values arbitrarily and use all the async stuff since the closure is async, like so (I'll write it in async/await syntax so you understand better)
when the closure returns, the flow terminates, if you throw inside the closure, then error is propagated as usual
It allow you to then create arbitrary custom operators, or simply way to pipe async function into AsyncSequence like
this is very needed
The text was updated successfully, but these errors were encountered: