Generic Structure
Publishers .Switch To Latest A publisher that “flattens” nested publishers.
SDKs
iOS 13.0+ macOS 10.15+ Mac Catalyst 13.0+ tvOS 13.0+ watchOS 6.0+ Xcode 11.0+ Declaration struct SwitchToLatest <P , Upstream > where P : Publisher , P == Upstream.Output, Upstream : Publisher , P.Failure == Upstream.Failure
Overview Given a publisher that publishes Publishers, the Switch To Latest
publisher produces a sequence of events from only the most recent one. For example, given the type Publisher<Publisher<Data, NSError>, Never>
, calling switch To Latest()
will result in the type Publisher<Data, NSError>
. The downstream subscriber sees a continuous stream of values even though they may be coming from different upstream publishers.
Topics
Instance Methods func combine Latest <P, Q, T>(P, Q, (P .Output, P .Output, Q .Output) -> T) -> Publishers .Map<Publishers .Combine Latest3<Publishers .Switch To Latest<P, Upstream>, P, Q>, T>
Subscribes to two additional publishers and invokes a closure upon receiving output from any of the publishers.
func combine Latest <P, Q, R, T>(P, Q, R, (P .Output, P .Output, Q .Output, R .Output) -> T) -> Publishers .Map<Publishers .Combine Latest4<Publishers .Switch To Latest<P, Upstream>, P, Q, R>, T>
Subscribes to three additional publishers and invokes a closure upon receiving output from any of the publishers.
func map <T0, T1, T2>(Key Path<P .Output, T0>, Key Path<P .Output, T1>, Key Path<P .Output, T2>) -> Publishers .Map Key Path3<Publishers .Switch To Latest<P, Upstream>, T0, T1, T2>
Publishes the values of three key paths as a tuple.
func merge <B, C, D, E>( with : B, C, D, E) -> Publishers .Merge5<Publishers .Switch To Latest<P, 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 .Switch To Latest<P, 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 .Switch To Latest<P, 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 .Switch To Latest<P, 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 zip <P, Q, T>(P, Q, (P .Output, P .Output, Q .Output) -> T) -> Publishers .Map<Publishers .Zip3<Publishers .Switch To Latest<P, Upstream>, P, Q>, T>
Combines elements from two other publishers and delivers a transformed output.
func zip <P, Q, R, T>(P, Q, R, (P .Output, P .Output, Q .Output, R .Output) -> T) -> Publishers .Map<Publishers .Zip4<Publishers .Switch To Latest<P, Upstream>, P, Q, R>, T>
Combines elements from three other publishers and delivers a transformed output.