Generic Instance Method

tryScan(_:_:)

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.

Declaration

func tryScan<T>(_ initialResult: T, _ nextPartialResult: @escaping (T, Upstream.Output) throws -> T) -> Publishers.TryScan<Publishers.Multicast<Upstream, SubjectType>, T>

Parameters

initialResult

The previous result returned by the nextPartialResult closure.

nextPartialResult

An error-throwing closure that takes as its arguments the previous value returned by the closure and the next element emitted from the upstream publisher.

Return Value

A publisher that transforms elements by applying a closure that receives its previous return value and the next element from the upstream publisher.

Discussion

If the closure throws an error, the publisher fails with the error.