This is Understanding Combine, written by Matt Neuburg. It is a work in progress. Corrections and suggestions are greatly appreciated (you can comment here). So are donations; please consider keeping me going by funding this work at Or buy my books: the current editions are iOS 13 Programming Fundamentals with Swift and Programming iOS 13. Thank you!


.output(at:) (Publishers.Output) takes an Int representing an index. When the value designated by that index arrives from upstream, it emits that value, cancels the upstream publisher, and sends a .finished completion. So, for example, 0 designates the first value from upstream, 1 designates the second value from upstream, and so on. If the upstream emits a .finished completion before the index is reached, this operator emits no values; it just passes the .finished completion on downstream.

.output(in:) (Publishers.Output) is like .output(at:) except that the parameter is a Range (of Int). It emits each value indexed by the numbers in the Range; after emitting the last value indexed by the Range, it cancels the upstream publisher and sends a .finished completion. If the upstream emits a .finished completion before the last index in the Range is reached, this operator stops publishing and passes the .finished completion on downstream.

The .output operator is badly named; something like .index might have been clearer.

Table of Contents