Skip to content

Instantly share code, notes, and snippets.

@Arrlindii
Created June 22, 2019 19:48
Show Gist options
  • Select an option

  • Save Arrlindii/5597a3161cdb13f40ed35f61f5ed68b6 to your computer and use it in GitHub Desktop.

Select an option

Save Arrlindii/5597a3161cdb13f40ed35f61f5ed68b6 to your computer and use it in GitHub Desktop.
let selectedFilter = PassthroughSubject<String, Never>()
let searchText = NotificationCenter.default
.publisher(for: UITextField.textDidChangeNotification, object: searchTextField)
.map( { ($0.object as! UITextField).text } )
.debounce(for: .milliseconds(500), scheduler: RunLoop.main)
.eraseToAnyPublisher()
let publisher = Publishers.CombineLatest(selectedFilter,searchText, transform: { selectedFilter, searchText in
"\(selectedFilter) \(searchText)"
})
_ = publisher.sink { value in
print(value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment