Flowable concatMapSingle without prefetch to ignore clicks until processing finishes

前端 未结 1 1761
野的像风
野的像风 2020-12-12 02:57

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 ba

相关标签:
1条回答
  • 2020-12-12 03:28

    Using flatMapSingle instead of concatMapSingle does the trick, as suggested by akarnokd on GitHub:

    flatMap will only fetch the next upstream item if the current one actually completed

    The last parameter is maxConcurrency, specifying the maximum number of active subscriptions to the SingleSources:

    clicks
        .onBackpressureDrop()
        .flatMapSingle(::handleClick, false, 1)
    

    In this instance, flatMapSingle subscribes to those Singles sequentially, so it doesn't change the semantics I got from concatMapSingle.

    0 讨论(0)
提交回复
热议问题