Generic Structure

Publishers.Debounce

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

Declaration

struct Debounce<Upstream, Context> where Upstream : Publisher, Context : Scheduler

Topics

Instance Properties

let dueTime: Context.SchedulerTimeType.Stride

The amount of time the publisher should wait before publishing an element.

let options: Context.SchedulerOptions?

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

let scheduler: Context

The scheduler on which this publisher delivers elements.

let upstream: Upstream

The publisher from which this publisher receives elements.

Instance Methods

func allSatisfy((Upstream.Output) -> Bool) -> Publishers.AllSatisfy<Publishers.Debounce<Upstream, Context>>

Publishes a single Boolean value that indicates whether all received elements pass a given predicate.

func assertNoFailure(String, file: StaticString, line: UInt) -> Publishers.AssertNoFailure<Publishers.Debounce<Upstream, Context>>

Raises a fatal error when its upstream publisher fails, and otherwise republishes all received input.

func assign<Root>(to: ReferenceWritableKeyPath<Root, Upstream.Output>, on: Root) -> AnyCancellable

Assigns the value of a KVO-compliant property from a publisher.

func `catch`<P>((Upstream.Failure) -> P) -> Publishers.Catch<Publishers.Debounce<Upstream, Context>, P>

Handles errors from an upstream publisher by replacing it with another publisher.

func collect() -> Publishers.Collect<Publishers.Debounce<Upstream, Context>>

Collects all received elements, and emits a single array of the collection when the upstream publisher finishes.

func collect(Int) -> Publishers.CollectByCount<Publishers.Debounce<Upstream, Context>>

Collects up to the specified number of elements, and then emits a single array of the collection.

func compactMap<T>((Upstream.Output) -> T?) -> Publishers.CompactMap<Publishers.Debounce<Upstream, Context>, T>

Calls a closure with each received element and publishes any returned optional that has a value.

func contains(Upstream.Output) -> Publishers.Contains<Publishers.Debounce<Upstream, Context>>

Publishes a Boolean value upon receiving an element equal to the argument.

func contains(where: (Upstream.Output) -> Bool) -> Publishers.ContainsWhere<Publishers.Debounce<Upstream, Context>>

Publishes a Boolean value upon receiving an element that satisfies the predicate closure.

func count() -> Publishers.Count<Publishers.Debounce<Upstream, Context>>

Publishes the number of elements received from the upstream publisher.

func decode<Item, Coder>(type: Item.Type, decoder: Coder) -> Publishers.Decode<Publishers.Debounce<Upstream, Context>, Item, Coder>

Decodes the output from upstream using a specified TopLevelDecoder. For example, use JSONDecoder.

func drop<P>(untilOutputFrom: P) -> Publishers.DropUntilOutput<Publishers.Debounce<Upstream, Context>, P>

Ignores elements from the upstream publisher until it receives an element from a second publisher.

func drop(while: (Upstream.Output) -> Bool) -> Publishers.DropWhile<Publishers.Debounce<Upstream, Context>>

Omits elements from the upstream publisher until a given closure returns false, before republishing all remaining elements.

func dropFirst(Int) -> Publishers.Drop<Publishers.Debounce<Upstream, Context>>

Omits the specified number of elements before republishing subsequent elements.

func encode<Coder>(encoder: Coder) -> Publishers.Encode<Publishers.Debounce<Upstream, Context>, Coder>

Encodes the output from upstream using a specified TopLevelEncoder. For example, use JSONEncoder.

func first() -> Publishers.First<Publishers.Debounce<Upstream, Context>>

Publishes the first element of a stream, then finishes.

func first(where: (Upstream.Output) -> Bool) -> Publishers.FirstWhere<Publishers.Debounce<Upstream, Context>>

Publishes the first element of a stream to satisfy a predicate closure, then finishes.

func ignoreOutput() -> Publishers.IgnoreOutput<Publishers.Debounce<Upstream, Context>>

Ingores all upstream elements, but passes along a completion state (finished or failed).

func last() -> Publishers.Last<Publishers.Debounce<Upstream, Context>>

Only publishes the last element of a stream, after the stream finishes.

func last(where: (Upstream.Output) -> Bool) -> Publishers.LastWhere<Publishers.Debounce<Upstream, Context>>

Only publishes the last element of a stream that satisfies a predicate closure, after the stream finishes.

func makeConnectable() -> Publishers.MakeConnectable<Publishers.Debounce<Upstream, Context>>

Creates a connectable wrapper around the publisher.

func map<T>((Upstream.Output) -> T) -> Publishers.Map<Publishers.Debounce<Upstream, Context>, T>

Transforms all elements from the upstream publisher with a provided closure.

func max() -> Publishers.Comparison<Publishers.Debounce<Upstream, Context>>

Publishes the maximum value received from the upstream publisher, after it finishes.

func max(by: (Upstream.Output, Upstream.Output) -> Bool) -> Publishers.Comparison<Publishers.Debounce<Upstream, Context>>

Publishes the maximum value received from the upstream publisher, using the provided ordering closure.

func merge(with: Publishers.Debounce<Upstream, Context>) -> Publishers.MergeMany<Publishers.Debounce<Upstream, Context>>

Combines elements from this publisher with those from another publisher of the same type, delivering an interleaved sequence of elements.

func merge<B, C>(with: B, C) -> Publishers.Merge3<Publishers.Debounce<Upstream, Context>, B, C>

Combines elements from this publisher with those from two other publishers, delivering an interleaved sequence of elements.

func merge<B, C, D>(with: B, C, D) -> Publishers.Merge4<Publishers.Debounce<Upstream, Context>, B, C, D>

Combines elements from this publisher with those from three other publishers, delivering an interleaved sequence of elements.

func merge<B, C, D, E>(with: B, C, D, E) -> Publishers.Merge5<Publishers.Debounce<Upstream, Context>, B, C, D, E>

Combines elements from this publisher with those from four other publishers, delivering an interleaved sequence of elements.

func merge<B, C, D, E, F>(with: B, C, D, E, F) -> Publishers.Merge6<Publishers.Debounce<Upstream, Context>, B, C, D, E, F>

Combines elements from this publisher with those from five other publishers, delivering an interleaved sequence of elements.

func merge<B, C, D, E, F, G>(with: B, C, D, E, F, G) -> Publishers.Merge7<Publishers.Debounce<Upstream, Context>, B, C, D, E, F, G>

Combines elements from this publisher with those from six other publishers, delivering an interleaved sequence of elements.

func merge<B, C, D, E, F, G, H>(with: B, C, D, E, F, G, H) -> Publishers.Merge8<Publishers.Debounce<Upstream, Context>, B, C, D, E, F, G, H>

Combines elements from this publisher with those from seven other publishers, delivering an interleaved sequence of elements.

func min() -> Publishers.Comparison<Publishers.Debounce<Upstream, Context>>

Publishes the minimum value received from the upstream publisher, after it finishes.

func min(by: (Upstream.Output, Upstream.Output) -> Bool) -> Publishers.Comparison<Publishers.Debounce<Upstream, Context>>

Publishes the minimum value received from the upstream publisher, after it finishes.

func output(at: Int) -> Publishers.Output<Publishers.Debounce<Upstream, Context>>

Publishes a specific element, indicated by its index in the sequence of published elements.

func output<R>(in: R) -> Publishers.Output<Publishers.Debounce<Upstream, Context>>

Publishes elements specified by their range in the sequence of published elements.

func prefix(Int) -> Publishers.Output<Publishers.Debounce<Upstream, Context>>

Republishes elements up to the specified maximum count.

func prefix(while: (Upstream.Output) -> Bool) -> Publishers.PrefixWhile<Publishers.Debounce<Upstream, Context>>

Republishes elements while a predicate closure indicates publishing should continue.

func reduce<T>(T, (T, Upstream.Output) -> T) -> Publishers.Reduce<Publishers.Debounce<Upstream, Context>, T>

Applies a closure that accumulates each element of a stream and publishes a final result upon completion.

func removeDuplicates() -> Publishers.RemoveDuplicates<Publishers.Debounce<Upstream, Context>>

Publishes only elements that don’t match the previous element.

func replaceNil<T>(with: T) -> Publishers.Map<Publishers.Debounce<Upstream, Context>, T>

Replaces nil elements in the stream with the proviced element.

func retry(Int) -> Publishers.Retry<Publishers.Debounce<Upstream, Context>>

Attempts to recreate a failed subscription with the upstream publisher using a specified number of attempts to establish the connection.

func scan<T>(T, (T, Upstream.Output) -> T) -> Publishers.Scan<Publishers.Debounce<Upstream, Context>, T>

Transforms elements from the upstream publisher by providing the current element to a closure along with the last value returned by the closure.

func setFailureType<E>(to: E.Type) -> Publishers.SetFailureType<Publishers.Debounce<Upstream, Context>, E>

Changes the failure type declared by the upstream publisher.

func subscribe<S>(S) -> AnyCancellable

Attaches the specified Subscriber to this Publisher.

func subscribe<S>(S)

Attaches the specified subscriber to this publisher.

func subscribe<S>(on: S, options: S.SchedulerOptions?) -> Publishers.SubscribeOn<Publishers.Debounce<Upstream, Context>, S>

Specifies the scheduler on which to perform subscribe, cancel, and request operations.

func switchToLatest() -> Publishers.SwitchToLatest<Upstream.Output, Publishers.Debounce<Upstream, Context>>

Flattens the stream of events from multiple upstream publishers to appear as if they were coming from a single stream of events.

func throttle<S>(for: S.SchedulerTimeType.Stride, scheduler: S, latest: Bool) -> Publishers.Throttle<Publishers.Debounce<Upstream, Context>, S>

Publishes either the most-recent or first element published by the upstream publisher in the specified time interval.

func tryAllSatisfy((Upstream.Output) -> Bool) -> Publishers.TryAllSatisfy<Publishers.Debounce<Upstream, Context>>

Publishes a single Boolean value that indicates whether all received elements pass a given error-throwing predicate.

func tryCompactMap<T>((Upstream.Output) -> T?) -> Publishers.TryCompactMap<Publishers.Debounce<Upstream, Context>, T>

Calls an error-throwing closure with each received element and publishes any returned optional that has a value.

func tryContains(where: (Upstream.Output) -> Bool) -> Publishers.TryContainsWhere<Publishers.Debounce<Upstream, Context>>

Publishes a Boolean value upon receiving an element that satisfies the throwing predicate closure.

func tryDrop(while: (Upstream.Output) -> Bool) -> Publishers.TryDropWhile<Publishers.Debounce<Upstream, Context>>

Omits elements from the upstream publisher until an error-throwing closure returns false, before republishing all remaining elements.

func tryFilter((Upstream.Output) -> Bool) -> Publishers.TryFilter<Publishers.Debounce<Upstream, Context>>

Republishes all elements that match a provided error-throwing closure.

func tryFirst(where: (Upstream.Output) -> Bool) -> Publishers.TryFirstWhere<Publishers.Debounce<Upstream, Context>>

Publishes the first element of a stream to satisfy a throwing predicate closure, then finishes.

func tryLast(where: (Upstream.Output) -> Bool) -> Publishers.TryLastWhere<Publishers.Debounce<Upstream, Context>>

Only publishes the last element of a stream that satisfies a error-throwing predicate closure, after the stream finishes.

func tryMap<T>((Upstream.Output) -> T) -> Publishers.TryMap<Publishers.Debounce<Upstream, Context>, T>

Transforms all elements from the upstream publisher with a provided error-throwing closure.

func tryMax(by: (Upstream.Output, Upstream.Output) -> Bool) -> Publishers.TryComparison<Publishers.Debounce<Upstream, Context>>

Publishes the maximum value received from the upstream publisher, using the provided error-throwing closure to order the items.

func tryMin(by: (Upstream.Output, Upstream.Output) -> Bool) -> Publishers.TryComparison<Publishers.Debounce<Upstream, Context>>

Publishes the minimum value received from the upstream publisher, using the provided error-throwing closure to order the items.

func tryPrefix(while: (Upstream.Output) -> Bool) -> Publishers.TryPrefixWhile<Publishers.Debounce<Upstream, Context>>

Republishes elements while a error-throwing predicate closure indicates publishing should continue.

func tryReduce<T>(T, (T, Upstream.Output) -> T) -> Publishers.TryReduce<Publishers.Debounce<Upstream, Context>, T>

Applies an error-throwing closure that accumulates each element of a stream and publishes a final result upon completion.

func tryScan<T>(T, (T, Upstream.Output) -> T) -> Publishers.TryScan<Publishers.Debounce<Upstream, Context>, T>

Transforms elements from the upstream publisher by providing the current element to an error-throwing closure along with the last value returned by the closure.

func zip<P>(P) -> Publishers.Zip<Publishers.Debounce<Upstream, Context>, P>

Combine elements from another publisher and deliver pairs of elements as tuples.

func zip<P, Q>(P, Q) -> Publishers.Zip3<Publishers.Debounce<Upstream, Context>, P, Q>

Combine elements from two other publishers and deliver groups of elements as tuples.

func zip<P, Q, R>(P, Q, R) -> Publishers.Zip4<Publishers.Debounce<Upstream, Context>, P, Q, R>

Combine elements from three other publishers and deliver groups of elements as tuples.

Relationships

Conforms To

See Also

Controlling Timing

struct Publishers.Delay

A publisher that delays delivery of elements and completion to the downstream receiver.

Beta
struct Publishers.MeasureInterval

A publisher that measures and emits the time interval between events received from an upstream publisher.

Beta
struct Publishers.Throttle

A publisher that publishes either the most-recent or first element published by the upstream publisher in a specified time interval.

Beta

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software