How can I debounce a method call?

Here’s an option for those not wanting to create classes/extensions:

Somewhere in your code:

var debounce_timer:Timer?

And in places you want to do the debounce:

debounce_timer?.invalidate()
debounce_timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: false) { _ in 
    print ("Debounce this...") 
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)