Generic Instance Method

compactMap(_:)

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

Declaration

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

Parameters

transform

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.