1010//===----------------------------------------------------------------------===//
1111
1212extension AsyncSequence {
13+ /// Creates an asynchronous sequence that emits the latest element after a given quiescence period
14+ /// has elapsed by using a spectified Clock.
1315 @available ( macOS 9999 , iOS 9999 , tvOS 9999 , watchOS 9999 , * )
1416 public func debounce< C: Clock > ( for interval: C . Instant . Duration , tolerance: C . Instant . Duration ? = nil , clock: C ) -> AsyncDebounceSequence < Self , C > {
1517 AsyncDebounceSequence ( self , interval: interval, tolerance: tolerance, clock: clock)
1618 }
1719
20+ /// Creates an asynchronous sequence that emits the latest element after a given quiescence period
21+ /// has elapsed.
1822 @available ( macOS 9999 , iOS 9999 , tvOS 9999 , watchOS 9999 , * )
1923 public func debounce( for interval: Duration , tolerance: Duration ? = nil ) -> AsyncDebounceSequence < Self , ContinuousClock > {
2024 debounce ( for: interval, tolerance: tolerance, clock: . continuous)
2125 }
2226}
2327
28+ /// An `AsyncSequence` that emits the latest element after a given quiescence period
29+ /// has elapsed.
2430@available ( macOS 9999 , iOS 9999 , tvOS 9999 , watchOS 9999 , * )
2531public struct AsyncDebounceSequence < Base: AsyncSequence , C: Clock > : Sendable
2632 where Base. AsyncIterator: Sendable , Base. Element: Sendable , Base: Sendable {
@@ -41,6 +47,7 @@ public struct AsyncDebounceSequence<Base: AsyncSequence, C: Clock>: Sendable
4147extension AsyncDebounceSequence : AsyncSequence {
4248 public typealias Element = Base . Element
4349
50+ /// The iterator for a `AsyncDebounceSequence` instance.
4451 public struct Iterator : AsyncIteratorProtocol , Sendable {
4552 enum Partial : Sendable {
4653 case sleep
0 commit comments