We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 41e160b commit 88cfef7Copy full SHA for 88cfef7
1 file changed
Tool/Sources/DebounceFunction/DebounceFunction.swift
@@ -11,6 +11,10 @@ public actor DebounceFunction<T> {
11
self.block = block
12
}
13
14
+ public func cancel() {
15
+ task?.cancel()
16
+ }
17
+
18
public func callAsFunction(_ t: T) async {
19
task?.cancel()
20
task = Task { [block, duration] in
@@ -29,6 +33,10 @@ public actor DebounceRunner {
29
33
self.duration = duration
30
34
31
35
36
37
38
39
32
40
public func debounce(_ block: @escaping () async -> Void) {
41
42
task = Task { [duration] in
@@ -37,3 +45,4 @@ public actor DebounceRunner {
45
46
47
48
0 commit comments