throttle method
Throttle value changes - callback is called at most once per duration
Implementation
void throttle(Duration duration, void Function(T value) callback) {
RxTimingUtils._register(this);
bool canCall = true;
void listener() {
if (canCall) {
canCall = false;
callback(value); // Use current value, not previous
final timer = Timer(duration, () {
canCall = true;
});
// Track the timer for cleanup
RxTimingUtils._getTimingData(this)?.addTimer(timer);
}
}
addListener(listener);
}