Skip to content

Instantly share code, notes, and snippets.

@eunjin3786
Last active June 28, 2019 05:03
Show Gist options
  • Save eunjin3786/bbefa7289da393c1ec224ff8d5c3fbae to your computer and use it in GitHub Desktop.
Save eunjin3786/bbefa7289da393c1ec224ff8d5c3fbae to your computer and use it in GitHub Desktop.
let subject = PassthroughSubject<String, Error>()
subject.send("Is anyone listening?")
let subcription1 = subject.sink(receiveCompletion: {
print("1) \($0)")
}, receiveValue: {
print("1) \($0)")
})
let subscription2 = subject.sink(receiveCompletion: {
print("2) \($0)")
}, receiveValue: {
print("2) \($0)")
})
subject.send("Hello")
subject.send(completion: .finished)
subject.send("Is alive?")
<Output>
1) Hello
2) Hello
1) finished
2) finished
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment