athanclark/elm-debouncer/2.0.0

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 b =
{ elapsed : Maybe (Elapsed b) }

The state of the debouncer

init : Model b

The initial debouncer

Starting the Debouncer

type Msg b
= Bounce (Maybe b -> Maybe b)

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

Evaluating the Debouncer

Time
-> (Maybe b -> Cmd a)
-> Msg b
-> Model b
-> ( Model b, Cmd (Result a (Msg b)) )

The main logic of the debouncer.