Generic Instance Method

debounce(for:scheduler:options:)

Publishes elements only after a specified time interval elapses between events.

Declaration

func debounce<S>(for dueTime: S.SchedulerTimeType.Stride, scheduler: S, options: S.SchedulerOptions? = nil) -> Publishers.Debounce<Publishers.Catch<Upstream, NewPublisher>, S> where S : Scheduler

Parameters

dueTime

The time the publisher should wait before publishing an element.

scheduler

The scheduler on which this publisher delivers elements

options

Scheduler options that customize this publisher’s delivery of elements.

Return Value

A publisher that publishes events only after a specified time elapses.

Discussion

Use this operator when you want to wait for a pause in the delivery of events from the upstream publisher. For example, call debounce on the publisher from a text field to only receive elements when the user pauses or stops typing. When they start typing again, the debounce holds event delivery until the next pause.