Skip to content
FutureBlitz

    Install

    Import std.time.timers

    Debounce

    std.time.timers

    class

    Public Class Debounce

    Acts once a burst of events has stopped: each Signal starts the delay again, and Ready says True once the delay has gone by since the latest, and then not again until another Signal.

    Examples

    Local start = Instant.FromNanoseconds(0)
    Local save = Debounce(300.Milliseconds)
    save.Signal(start)
    save.Signal(start + 100.Milliseconds)
    Expect(!save.Ready(start + 300.Milliseconds))
    Expect(save.Ready(start + 400.Milliseconds) && !save.IsPending)

    std/time/timers.fb, line 384

    • @PanicsAtCaller Public New(delay: Duration) constructor #

      A Debounce of that delay, which panics for one below 0.

    • Public Method Signal() method #

      An event, now or at the Instant.

    • Public Method Signal(now: Instant) method #

      An event at now.

    • Public Property IsPending: Bool property #

      Whether a Signal waits for its delay.

    • Public Method Ready(): Bool method #

      Whether to act, now or at the Instant: True once the delay has gone by since the latest Signal, which it then forgets.

    • Public Method Ready(now: Instant): Bool method #

      Whether to act at now: True once the delay has gone by since the latest Signal, which it then forgets.

    • Public Method Cancel() method #

      Forgets the latest Signal.

    Report an issue with this page or with FutureBlitz on GitHub.