It seems like a combination of collect(every:on:skipEmpty:discardWhenCompleted:) and collect(count:) in ReactiveSwift.
The resulting signal would send an event every n seconds if the count of accumulated values doesn't reach max count during each time interval. But if in a specific time interval, the count of values has reached max count, it will send immediately.
For example, timeInterval = 2s, maxCount = 2

- interval 1: received two values [1, 2], forward them at end of interval 1
- interval 2: received one value [3], forward them at end of interval 2
- interval 3: received three values [5, 6, 7] ( 3 values > maxCount), forward [5, 6] immediately when 7 is received and 7 is regarded as received value in interval 4 (interval 3 stopped early)
It collects an array of values until it reaches a certain count and then fires or fires every time interval.
Test:
Output: