CombineExt icon indicating copy to clipboard operation
CombineExt copied to clipboard

Add DelaySubscription Operator

Open Jackstone92 opened this issue 4 years ago • 1 comments

Hi everyone,

It would be great if a Combine implementation of the DelaySubscription operator could be added to this repo in order to further reduce the number of missing operators when compared with other reactive libraries (eg. RxSwift as per the cheat sheet).

As we'd expect from existing implementations found in other libraries, this DelaySubscription operator would allow a subscription to be time-shifted. This means that rather than shifting all emissions of a publisher forward in time (as per the current Delay implementation), only the subscription would be delayed.

Using a real-world example of a live video streaming app to explain the desired difference, if the streaming source was emitting frames (a "hot" publisher), then using .delay(for: .seconds(3), scheduler: scheduler) would mean that when sinked on, frames would be received 3 seconds behind the actual emission. By using .delaySubscription(for: .seconds(3), scheduler: scheduler) this would mean that after the initial 3 second delay (where frames would be dropped), frames would then be received in real time.

Jackstone92 avatar Mar 07 '21 02:03 Jackstone92

@Jackstone92 https://github.com/CombineCommunity/CombineExt/pull/117

mihai8804858 avatar Mar 01 '22 14:03 mihai8804858