Documentation / dataflow-async / com.femastudios.dataflow.async / Attribute / debounced
Go to reference

debounced

open fun debounced(delay: Long, maxDelay: Long?): TimeShiftedAttribute<T>

Returns a TimeShiftedAttribute whose value is debounced at with the specified delay (in milliseconds). When the original value changes, a countdown of delay milliseconds starts: if another change happens during this countdown the countdown is reset at delay milliseconds. When the countdown finishes the latest change is propagated to the new attribute.

When the maxDelay parameter is not null ensures that the maximum time between updates is maxDelay milliseconds: this avoids a possible extreme case where continuous updates of this attribute constantly push the update of the TimeShiftedAttribute forward.


open fun debounced(delay: Long): TimeShiftedAttribute<T>

Same as Attribute.debounced but with a null max delay.


open fun debounced(delay: (debouncedValue: AttributeData<T>, newValue: AttributeData<T>) -> Long): TimeShiftedAttribute<T>
open fun debounced(delay: (debouncedValue: AttributeData<T>, newValue: AttributeData<T>) -> Long, maxDelay: Long?): TimeShiftedAttribute<T>

Same as Attribute.debounced but the delay is a lambda called each time the attribute changes.