OxL Справочник OxL
РусскийEnglish

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:

oxl✓ проверяется в CI
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

Параметры

ИмяТип
sstream<T, E>
dDuration

Возвращает

stream<T, E>

Эффекты

time

Определено в: std/stream/stream.oxl:488

См. также