mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
Debouncing and form validation improvements
This commit is contained in:
15
Shared/Debounce.swift
Normal file
15
Shared/Debounce.swift
Normal 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()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user