Created
June 22, 2019 19:40
-
-
Save Arrlindii/f73127c14b5e7ad932078cdbc571c55c to your computer and use it in GitHub Desktop.
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 = PassthroughSubject<String, Never>() | |
| let publisher = subject.eraseToAnyPublisher() | |
| let subscriber1 = publisher.sink(receiveValue: { value in | |
| print(value) | |
| }) | |
| //subscriber1 will recive the events but not the subscriber2 | |
| subject.send("Event1") | |
| subject.send("Event2") | |
| let subscriber2 = publisher.sink(receiveValue: { value in | |
| print(value) | |
| }) | |
| //Subscriber1 and Subscriber2 will recive this event | |
| subject.send("Event3") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment