Generic Instance Method


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


func compactMap<T>(_ transform: @escaping (Upstream.Output) -> T?) -> Publishers.CompactMap<Publishers.Share<Upstream>, T>



A closure that receives a value and returns an optional value.

Return Value

A publisher that republishes all non-nil results of calling the transform closure.

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