Here’s a list of custom operators I had to build at some point

Every

The every(interval:on:in:) operator allows a publisher to emit values at a certain frequency.

public extension Publisher where Failure == Never {
  func every(_ interval: TimeInterval, on runLoop: RunLoop, in mode: RunLoop.Mode)
    -> AnyPublisher<Self.Output, Self.Failure> {
        let delayPublisher = Timer.publish(every: interval, on: runLoop, in: mode).autoconnect()
        let delayedValuesPublisher = Publishers.Zip(self, delayPublisher)
        return delayedValuesPublisher
            .map { $0.0 }
            .eraseToAnyPublisher()
  }
}

var disposables = Set<AnyCancellable>()

[0.1, 0.2, 0.3 ,0.5 ,0.7, 1.0].publisher
    .every(1.0, on: .main, in: .default)
    .sink { print($0) }
    .store(in: &disposables)

Lasting

The last(atLeast:on:) operator allows a to take at least a certain amount of time to finish

public extension Publisher where Failure == Error {
  func lasting(atLeast stride: RunLoop.SchedulerTimeType.Stride, on runLoop: RunLoop)
    -> AnyPublisher<Self.Output, Self.Failure> {
        let lastingPublisher = Just(())
            .setFailureType(to: Error.self)
            .delay(for: stride, scheduler: runLoop)

        let delayedValuesPublisher = Publishers.Zip(self, lastingPublisher)
        return delayedValuesPublisher
            .map { $0.0 }
            .eraseToAnyPublisher()
  }
}

var disposables = Set<AnyCancellable>()

Just(())
    .setFailureType(to: Error.self)
    .lasting(atLeast: 1.0, on: .main)
    .sink(
        receiveCompletion: { _ in print("Completion") },
        receiveValue: { print($0) }
    )
    .store(in: &disposables)