Created
December 17, 2021 19:54
-
-
Save rmirabelli/8af78d509d1deba87a4a638a315cdfa8 to your computer and use it in GitHub Desktop.
A sample from Apple's Documentation for Pub/Sub in Comine
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 sub = NotificationCenter.default | |
.publisher(for: NSControl.textDidChangeNotification, object: filterField) | |
.map( { ($0.object as! NSTextField).stringValue } ) | |
.filter( { $0.unicodeScalars.allSatisfy({CharacterSet.alphanumerics.contains($0)}) } ) | |
.debounce(for: .milliseconds(500), scheduler: RunLoop.main) | |
.receive(on: RunLoop.main) | |
.assign(to:\MyViewModel.filterString, on: myViewModel) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment