Swift Combine: Buffer upstream values and emit them at a steady rate?

后端 未结 4 948
被撕碎了的回忆
被撕碎了的回忆 2021-02-06 04:16

Using the new Combine framework in iOS 13.

Suppose I have an upstream publisher sending values at a highly irregular rate - sometimes seconds or minutes may go by withou

4条回答
  •  再見小時候
    2021-02-06 04:56

    Could Publishers.CollectByTime be useful here somewhere?

    Publishers.CollectByTime(upstream: upstreamPublisher.share(), strategy: Publishers.TimeGroupingStrategy.byTime(RunLoop.main, .seconds(1)), options: nil)
    

提交回复
热议问题