Instance Method

collect()

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

Declaration

func collect() -> Publishers.Collect<Publishers.Concatenate<Prefix, Suffix>>

Return Value

A publisher that collects all received items and returns them as an array upon completion.

Discussion

If the upstream publisher fails with an error, this publisher forwards the error to the downstream receiver instead of sending its output. This publisher requests an unlimited number of elements from the upstream publisher. It only sends the collected array to its downstream after a request whose demand is greater than 0 items. Note: This publisher uses an unbounded amount of memory to store the received values.

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