Debouncing and form validation improvements

This commit is contained in:
Arkadiusz Fal
2021-09-26 22:12:43 +02:00
parent f9396985c9
commit a0f74a5899
10 changed files with 168 additions and 96 deletions

15
Shared/Debounce.swift Normal file
View File

@@ -0,0 +1,15 @@
import Foundation
struct Debounce {
private var timer: Timer?
mutating func debouncing(_ interval: TimeInterval, action: @escaping () -> Void) {
timer = Timer.scheduledTimer(withTimeInterval: interval, repeats: false) { _ in
action()
}
}
func invalidate() {
timer?.invalidate()
}
}