Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
private(set) var searchTermThrottle = Throttler<String>(1.5)
override func viewDidLoad() {
searchField.addTarget(self, action: #selector(textDidChange(_:)), for: .editingChanged)
searchTermThrottle.on { (searchTerm) in searchTerm) { [weak self] result in
switch (result) {
case .success(let models): self?.onSuccess(models)
case .failure(let error): self?.onError(error)
@objc func textDidChange(_ sender: UITextField) {
searchTermThrottle.receive(sender.text ?? "")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.