Skip to content

Instantly share code, notes, and snippets.

@gtokman
Created March 28, 2021 14:35
Show Gist options
  • Select an option

  • Save gtokman/430bada786669ba043493a23978a556b to your computer and use it in GitHub Desktop.

Select an option

Save gtokman/430bada786669ba043493a23978a556b to your computer and use it in GitHub Desktop.
AnyCancellable -combine
// 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