Created
April 27, 2020 23:19
-
-
Save masliukivskyi/867a35b7c5e8ca8e579c84b27293d72b 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 subject = CurrentValueSubject<String, Never>("This text should not be sent") | |
subject.send("π") | |
let subscriber1 = subject.sink { (value) in | |
print("First subscriber received value: \(value)") | |
} | |
subject.send("πΆ") | |
let subscriber2 = subject.sink { (value) in | |
print("Second subscriber received value: \(value)") | |
} | |
subject.send("πβ) | |
Output: | |
First subscriber received value: π | |
First subscriber received value: πΆ | |
Second subscriber received value: πΆ | |
First subscriber received value: π | |
Second subscriber received value: π |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment