10
10
//===----------------------------------------------------------------------===//
11
11
12
12
extension AsyncSequence {
13
+ /// Creates an asynchronous sequence that emits the latest element after a given quiescence period
14
+ /// has elapsed by using a spectified Clock.
13
15
@available ( macOS 9999 , iOS 9999 , tvOS 9999 , watchOS 9999 , * )
14
16
public func debounce< C: Clock > ( for interval: C . Instant . Duration , tolerance: C . Instant . Duration ? = nil , clock: C ) -> AsyncDebounceSequence < Self , C > {
15
17
AsyncDebounceSequence ( self , interval: interval, tolerance: tolerance, clock: clock)
16
18
}
17
19
20
+ /// Creates an asynchronous sequence that emits the latest element after a given quiescence period
21
+ /// has elapsed.
18
22
@available ( macOS 9999 , iOS 9999 , tvOS 9999 , watchOS 9999 , * )
19
23
public func debounce( for interval: Duration , tolerance: Duration ? = nil ) -> AsyncDebounceSequence < Self , ContinuousClock > {
20
24
debounce ( for: interval, tolerance: tolerance, clock: . continuous)
21
25
}
22
26
}
23
27
28
+ /// An `AsyncSequence` that emits the latest element after a given quiescence period
29
+ /// has elapsed.
24
30
@available ( macOS 9999 , iOS 9999 , tvOS 9999 , watchOS 9999 , * )
25
31
public struct AsyncDebounceSequence < Base: AsyncSequence , C: Clock > : Sendable
26
32
where Base. AsyncIterator: Sendable , Base. Element: Sendable , Base: Sendable {
@@ -41,6 +47,7 @@ public struct AsyncDebounceSequence<Base: AsyncSequence, C: Clock>: Sendable
41
47
extension AsyncDebounceSequence : AsyncSequence {
42
48
public typealias Element = Base . Element
43
49
50
+ /// The iterator for a `AsyncDebounceSequence` instance.
44
51
public struct Iterator : AsyncIteratorProtocol , Sendable {
45
52
enum Partial : Sendable {
46
53
case sleep
0 commit comments