Skip to content

Instantly share code, notes, and snippets.

@kalupas226
Created December 23, 2022 16:04
Show Gist options
  • Save kalupas226/8f3d900361e5080b982d11ffc2072043 to your computer and use it in GitHub Desktop.
Save kalupas226/8f3d900361e5080b982d11ffc2072043 to your computer and use it in GitHub Desktop.
SwiftUI debounce sample
import SwiftUI
struct ContentView: View {
@State private var query = ""
var body: some View {
TextField(
"Input text",
text: $query
)
.task(id: query) {
do {
try await Task.sleep(nanoseconds: NSEC_PER_SEC)
print("action")
} catch {}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment