Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
val networkTrigger = Channel<Unit>(capacity = Channel.RENDEZVOUS)
val diskCommands = Channel<DiskCommand>(capacity = Channel.RENDEZVOUS)
launch {
// trigger first load
val networkFlow = networkTrigger
.filter { it }
.flatMapLatest { }
.doOnEach { diskCommands.send(DiskCommand.Stop(stopAck)); write(it) }
.map{ diskCommands.send(DiskCommand.Read(it))}
val diskFlow = flattenMerge(diskCommands.consumeAsFlow(), networkFlow)
.flatmapLatest{ when (command) {....} //something from here can call networkTrigger(Unit) to kick off network request
return diskFlow //not sure what combine is needed for
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.