athanclark/elm-debouncer/4.0.0

NOTE: the latest version is 4.0.1

Debounce

This is a delay-based debouncer, where given a minimum delay and an action to issue, we'll build a stateful component that will eventually issue the action once, after being given a slew of requests within the delay timeframe.

Debouncer State

type alias Model a =
{ elapsed : Maybe (Elapsed a) }

The state of the debouncer

init : Model a

The initial debouncer

Starting the Debouncer

type Msg a
= Bounce (Cmd a)
| Assign (Cmd a) Posix
| Finish Posix

To bounce the debouncer, just make multiple calls to Bounce.

Evaluating the Debouncer

update : Posix -> Msg a -> Model a -> ( Model a, Cmd (Result (Msg a) a) )

The main logic of the debouncer.