Skip to content

Instantly share code, notes, and snippets.

@masliukivskyi
Created April 27, 2020 23:16
Show Gist options
  • Save masliukivskyi/279cd93c80b1a61565b66a894bf74784 to your computer and use it in GitHub Desktop.
Save masliukivskyi/279cd93c80b1a61565b66a894bf74784 to your computer and use it in GitHub Desktop.
Basics of Combine
let sequence = Publishers.Sequence<[String], Never>(sequence: ["Hello", "World”])
sequence
.sink(receiveCompletion: { (completion) in
switch completion {
case .finished:
print("Finished")
case .failure(let error):
print("Finished with error \(error)")
}
}) { (value) in
print("Received value: \(value)")
}
Output:
Received value: Hello
Received value: World
Finished
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment