Last active
June 28, 2019 05:18
-
-
Save eunjin3786/0a9a1536d77de08667ee8506c0eb4e9f to your computer and use it in GitHub Desktop.
This file contains 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 subject = CurrentValueSubject<String, Error>.init("Init Value") | |
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) Init Value | |
2) Init Value | |
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