athanclark/elm-debouncer/1.0.1

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 Debouncer b =
{ since : Maybe ( Time, b ) }

The state of the debouncer

initDebouncer : Debouncer b

The initial debouncer

Starting the Debouncer

= Bounce b

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

Evaluating the Debouncer

Time
-> (b -> a)
-> DebouncerMsg b
-> Debouncer b
-> ( Debouncer b, Cmd (DebouncerResults b a) )

The main logic of the debouncer.

Representing either more messages needing to be handled in this component, or the message you've been trying to debounce.

handleDebouncerResults : (DebouncerMsg b -> a) -> DebouncerResults b a -> a

By being able to convert a DebouncerMsg to a message we understand, we can turn a whole DebouncerResults to a message we understand.