-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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
asyncSequence {
await someFunction()
}
.flatMapLatest { ... }
.collect { ... }
this is very needed
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request