fn debounce
Emits an element only after d passed without a newer one (the last element of a burst); the pending element is
emitted when the stream ends.
Example:
use std.stream { debounce }
fn burst() -> stream<i32> {
for i in 1..=3 { yield i }
}
fn main() io, time {
var out: List<i32> = []
// a burst collapses into its last element
for await x in burst() |> debounce(50ms) {
out.push(x)
}
print("{out}")
}Вывод
[3]
pub(api) fn debounce<T, E>(s: stream<T, E>, d: Duration) -> stream<T, E> timeСложность. O(1) per element.
С версии. 1.0.0-beta
Параметры
Возвращает
stream<T, E>
Эффекты
time
Определено в: std/stream/stream.oxl:488