# Slider defer updates timing change

**URL:** <https://forum.inductiveautomation.com/t/slider-defer-updates-timing-change/93350>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [July 17, 2024, 8:34pm UTC](https://forum.inductiveautomation.com/t/slider-defer-updates-timing-change/93350 "2024-07-17T20:34:44Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![louagejasper](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/louagejasper/32/86311_2.png) [@louagejasper](https://forum.inductiveautomation.com/u/louagejasper)\
**Post date:** [February 7, 2025, 10:40am UTC](https://forum.inductiveautomation.com/t/slider-defer-updates-timing-change/93350/5 "2025-02-07T10:40:41Z")

</div>

> [@louagejasper](#):
>
> ```python
> from threading import Timer
> from functools import wraps
> 
> # Initialize counter
> c = 1
> 
> # Get logger instance
> logger = system.util.getLogger("testdebounce")
> 
> def debounce(duration):
> """Decorator to debounce function calls within a given duration."""
> def decorator(func):
> @wraps(func)
> def wrapper(*args, **kwargs):
> global c
> indx = c # Capture the current counter value
> 
> def debounce_msg():
> """Executes the function if it's the last invocation within the debounce period."""
> if c - 1 == indx:
> func(*args, **kwargs)
> 
> # Start the timer to check if this is the last call
> Timer(duration, debounce_msg).start()
> 			
> # Increment the counter
> c += 1
> 
> return wrapper
> return decorator
> 
> @debounce(0.3)
> def printDebounce(msg, indx):
> """Logs the message with debounce applied."""
> logger.info(msg)
> 
> ```

@pturmel do you think this is dangerous code?

---

_[View the full topic](https://forum.inductiveautomation.com/t/slider-defer-updates-timing-change/93350)._
