In Apple's 2019 WWDC video Swift Combine in Practice
, they demonstrate using a debounce
publisher to slow down the rate of messages.
return $username
.debounce(for: 0.5, scheduler: RunLoop.main)
.removeDuplicates()
.eraseToAnyPublisher()
However, anytime I attempt to use it in a similar fashion, I get the following error:
Cannot invoke 'debounce' with an argument list of type '(for: Double, scheduler: RunLoop)'
The debounce()
signature is:
public func debounce<S>(for dueTime: S.SchedulerTimeType.Stride,
scheduler: S,
options: S.SchedulerOptions? = nil) ->
Publishers.Debounce<Self, S> where S : Scheduler
SchedulerTimeType.Stride
appears to be initializable with a numeric but it's not working for me or my inexperience with Swift Generics is on display.
What is the correct way to call this?
Edit
Duplicate of this question...
Searching for generic words like "Combine" is, for now, rather challenging...
macOS 10.15, Xcode 11