The Debouncer. See the full example here.
The messages that are used internally.
Config contains the debouncing strategy and the message transformation.
This config should be constant and shared between update function and push function.
Initialize the debouncer. Call this from your init function.
Strategy defines the timing when commands are sent.
Send command as soon as it gets ready, with given rate limit. (a.k.a. Throttle)
Note: The first command will be sent immidiately.
Similar to soon, but send first command after offset time.
Send command after becomming stable, with given delay time. (a.k.a. Debounce)
This function consumes values and send a command.
If you want to postpone sending, return the values back to keep them.
Send a command using the latest value.
Send a command using all the accumulated values.
This is the component's update function following the Elm Architecture.
e.g. Saving the last value.
(debounce, cmd) =
Debounce.update
{ strategy = Debounce.later (1 * second)
, transform = DebounceMsg
}
(Debounce.takeLast save) -- save : value -> Cmd Msg
msg
model.debounceThe config should be constant and shared with push function.
The sending logic can depend on the current model. If you want to stop sending, return Cmd.none.
Push a value into the debouncer.
The state of the debouncer.
It is parameterized with the value type
a.