Created
April 27, 2020 23:16
-
-
Save masliukivskyi/279cd93c80b1a61565b66a894bf74784 to your computer and use it in GitHub Desktop.
Basics of Combine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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