Skip to content

Commit f560d1c

Browse files
authored
First pass at some documentation for debounce (#95)
* First pass at some documentation for debounce * Add additional docs for extension methods and iterator
1 parent 7f3df92 commit f560d1c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Sources/AsyncAlgorithms/AsyncDebounceSequence.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,23 @@
1010
//===----------------------------------------------------------------------===//
1111

1212
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.
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, *)
2531
public 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
4147
extension 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

Comments
 (0)