Created
December 23, 2022 16:04
-
-
Save kalupas226/8f3d900361e5080b982d11ffc2072043 to your computer and use it in GitHub Desktop.
SwiftUI debounce sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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