I want to handle clicks in such a way that they are ignored as long as I'm doing processing of some click that occurred.
I thought I could do it by utilizing the backpressure, like this:
private val clicks = PublishProcessor.create<Unit>()
// ...
clicks
.onBackpressureDrop()
.concatMapSingle(::handleClick, 0)
But this throws an error, because there's a requirement that concatMapSingle
needs to prefetch at least one item, which makes it queue the click and process it immediately after I'm done processing, which is not what I want. I want to process the click only if there is no processing happening at the moment.
Is there some other operator I could use to achieve the desired effect?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…