package miaou-core

  1. Overview
  2. Docs
Miaou core/widgets (no drivers, no SDL)

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.5.2.tar.gz
md5=60a3b9f181f24572a06a9492532bfdda
sha512=fcc35a275066be2900e6201782faf47503076fa4640f08cf78067835a6f447b74613009e55b2ac799adb7ca46f1bffa261fc5971753f2cc3c6bef327511c7ef6

doc/miaou-core.helpers/Miaou_helpers/Debounce/index.html

Module Miaou_helpers.DebounceSource

Generic debounce timer for deferring operations during rapid input.

This module provides a thread-safe debounce mechanism useful for:

  • Deferring expensive validation until typing pauses
  • Rate-limiting filesystem operations during path editing
  • Coalescing rapid UI events

Example usage:

  let debouncer = Debounce.create ~debounce_ms:250 ()

  (* On each input event *)
  let on_input () =
    Debounce.mark debouncer;
    Render_notify.request_render ()

  (* In service_cycle *)
  let service_cycle state _ =
    if Debounce.check_and_clear debouncer then
      run_expensive_operation state
    else
      state
Sourcetype t

A debounce timer instance.

Sourceval create : ?debounce_ms:int -> unit -> t

Create a new debounce timer.

  • parameter debounce_ms

    Minimum time in milliseconds between the last event and when is_ready returns true. Default: 250ms.

Sourceval mark : t -> unit

Mark that an event occurred. Resets the debounce timer and sets pending.

Sourceval is_ready : t -> bool

Check if the debounce period has elapsed since the last event. Returns true if there's a pending event and enough time has passed.

Sourceval clear : t -> unit

Clear the pending state after handling the debounced event.

Sourceval has_pending : t -> bool

Check if there's a pending event (regardless of whether debounce elapsed).

Sourceval debounce_ms : t -> int

Get the configured debounce period in milliseconds.

Sourceval check_and_clear : t -> bool

Convenience: check if ready and automatically clear if so. Returns true if the action should be performed now.