Created
March 28, 2021 14:35
-
-
Save gtokman/430bada786669ba043493a23978a556b to your computer and use it in GitHub Desktop.
AnyCancellable -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
| // many publishers | |
| var cancellables = Set<AnyCancellable>() | |
| $textSubject | |
| .compactMap { $0 } | |
| .assign(to: \.text, on: label) | |
| .store(in: &cancellables) | |
| // or single publisher | |
| var cancellable: AnyCancellable? | |
| cancellable = ["hello world"].publisher | |
| .sink { | |
| print($0) | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment