athanclark/elm-debouncer/3.0.2

NOTE: this package is not compatible with Elm 0.19.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)

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

Evaluating the Debouncer

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

The main logic of the debouncer.