Skip to content

Instantly share code, notes, and snippets.

@jasdev
Created January 24, 2021 04:44
Show Gist options
  • Save jasdev/88dc714541995b37504615d13856960f to your computer and use it in GitHub Desktop.
Save jasdev/88dc714541995b37504615d13856960f to your computer and use it in GitHub Desktop.
An example of Publishers.Zip completing even if only one of the inner publishers completes.
import Combine
let first = PassthroughSubject<Int, Never>()
let second = Just(2)
let cancellable = first
.zip(second)
.sink(receiveCompletion: { print($0) }, receiveValue: { print($0) })
first.send(1)
// Outputs:
// ```
// (1, 2)
// finished
// ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment