This provides a component that can "debounce" a changing value: monitor a time-varying sequence of values and output the latest value every time there is no further change for some minimum interval.
This implementation attempts to minimize the number of update calls by using
Process.sleep to manage the settling time (rather than recalculating elapsed
interval on every fine-grained tick). An added tuple element in the update
function's return value provides the notification to the parent of the settled
value. It's also possible to poll the settled value.
Use the Change message to pass a new value to debouncer.
Initialize the debouncer with the time interval (in milliseconds) to wait for changing values to settle and the initial settled value.
Update the debouncer as a typical TEA component. The return value adds a
final tuple element that is Nothing while the value is still changing and
Just x when the value has settled to x.
Access the settled value.
Debouncer model. Each instance handles a single time-varying sequence of the same type (the
datatype).