Debouncer.swift
into your projecthttps://github.com/moridaffy/msdebouncer/
main
branchHere's how you can use MSDebouncer in your app:
import MSDebouncer
class ViewController: UIViewController {
...
private var debouncer: Debouncer<String>?
private func setupDebouncer() {
self.debouncer = Debouncer(outputType: String.self, debounceTime: 1.0, callback: { value in
APIManager.shared.searchForItems(query: value)
})
}
private func textFieldUpdated(with text: String) {
debouncer?.setValue(text)
}
}
This snippet shows basic implementation of Debouncer when trying to implement live search in your app. It allows you to skip sending network requests to your API after each letter typed while still giving impression of instant search.
link |
Stars: 0 |
Last commit: 2 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics