Generic Structure

Publishers.Buffer

A publisher that buffers elements from an upstream publisher.

Declaration

struct Buffer<Upstream> where Upstream : Publisher

Topics

Instance Methods

func allSatisfy((Upstream.Output) -> Bool) -> Publishers.AllSatisfy<Publishers.Buffer<Upstream>>

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.Buffer<Upstream>>

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.Buffer<Upstream>, P>

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

func collect() -> Publishers.Collect<Publishers.Buffer<Upstream>>

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

func collect(Int) -> Publishers.CollectByCount<Publishers.Buffer<Upstream>>

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.Buffer<Upstream>, T>

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

func contains(Upstream.Output) -> Publishers.Contains<Publishers.Buffer<Upstream>>

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

func contains(where: (Upstream.Output) -> Bool) -> Publishers.ContainsWhere<Publishers.Buffer<Upstream>>

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

func count() -> Publishers.Count<Publishers.Buffer<Upstream>>

Publishes the number of elements received from the upstream publisher.

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

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

func drop<P>(untilOutputFrom: P) -> Publishers.DropUntilOutput<Publishers.Buffer<Upstream>, 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.Buffer<Upstream>>

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

func dropFirst(Int) -> Publishers.Drop<Publishers.Buffer<Upstream>>

Omits the specified number of elements before republishing subsequent elements.

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

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

func first() -> Publishers.First<Publishers.Buffer<Upstream>>

Publishes the first element of a stream, then finishes.

func first(where: (Upstream.Output) -> Bool) -> Publishers.FirstWhere<Publishers.Buffer<Upstream>>

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

func ignoreOutput() -> Publishers.IgnoreOutput<Publishers.Buffer<Upstream>>

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

func last() -> Publishers.Last<Publishers.Buffer<Upstream>>

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

func last(where: (Upstream.Output) -> Bool) -> Publishers.LastWhere<Publishers.Buffer<Upstream>>

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

func makeConnectable() -> Publishers.MakeConnectable<Publishers.Buffer<Upstream>>

Creates a connectable wrapper around the publisher.

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

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

func mapError<E>((Upstream.Failure) -> E) -> Publishers.MapError<Publishers.Buffer<Upstream>, E>

Converts any failure from the upstream publisher into a new error.

func max() -> Publishers.Comparison<Publishers.Buffer<Upstream>>

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

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

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

func measureInterval<S>(using: S, options: S.SchedulerOptions?) -> Publishers.MeasureInterval<Publishers.Buffer<Upstream>, S>

Measures and emits the time interval between events received from an upstream publisher.

func merge(with: Publishers.Buffer<Upstream>) -> Publishers.MergeMany<Publishers.Buffer<Upstream>>

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.Buffer<Upstream>, 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.Buffer<Upstream>, 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.Buffer<Upstream>, 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.Buffer<Upstream>, 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.Buffer<Upstream>, 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.Buffer<Upstream>, 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.Buffer<Upstream>>

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

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

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

func output(at: Int) -> Publishers.Output<Publishers.Buffer<Upstream>>

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

func output<R>(in: R) -> Publishers.Output<Publishers.Buffer<Upstream>>

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

func prefix(Int) -> Publishers.Output<Publishers.Buffer<Upstream>>

Republishes elements up to the specified maximum count.

func prefix(while: (Upstream.Output) -> Bool) -> Publishers.PrefixWhile<Publishers.Buffer<Upstream>>

Republishes elements while a predicate closure indicates publishing should continue.

func receive<S>(on: S, options: S.SchedulerOptions?) -> Publishers.ReceiveOn<Publishers.Buffer<Upstream>, S>

Specifies the scheduler on which to receive elements from the publisher.

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

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

func removeDuplicates() -> Publishers.RemoveDuplicates<Publishers.Buffer<Upstream>>

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

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

Replaces nil elements in the stream with the proviced element.

func retry(Int) -> Publishers.Retry<Publishers.Buffer<Upstream>>

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.Buffer<Upstream>, 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.Buffer<Upstream>, E>

Changes the failure type declared by the upstream publisher.

func subscribe<S>(S)

Attaches the specified subscriber to this publisher.

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

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

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

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.Buffer<Upstream>, 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.Buffer<Upstream>>

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.Buffer<Upstream>, 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.Buffer<Upstream>>

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

func tryDrop(while: (Upstream.Output) -> Bool) -> Publishers.TryDropWhile<Publishers.Buffer<Upstream>>

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.Buffer<Upstream>>

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

func tryFirst(where: (Upstream.Output) -> Bool) -> Publishers.TryFirstWhere<Publishers.Buffer<Upstream>>

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

func tryLast(where: (Upstream.Output) -> Bool) -> Publishers.TryLastWhere<Publishers.Buffer<Upstream>>

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.Buffer<Upstream>, 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.Buffer<Upstream>>

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.Buffer<Upstream>>

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.Buffer<Upstream>>

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

func tryReduce<T>(T, (T, Upstream.Output) -> T) -> Publishers.TryReduce<Publishers.Buffer<Upstream>, 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.Buffer<Upstream>, 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.Buffer<Upstream>, P>

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

func zip<P, Q>(P, Q) -> Publishers.Zip3<Publishers.Buffer<Upstream>, 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.Buffer<Upstream>, P, Q, R>

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

Relationships

Conforms To

See Also

Buffering Elements

enum Publishers.BufferingStrategy

A strategy for handling exhaustion of a buffer’s capacity.

enum Publishers.PrefetchStrategy

A strategy for filling a buffer.