Skip to content

Instantly share code, notes, and snippets.

@marc-hughes marc-hughes/debouce.dart
Last active Nov 1, 2018

What would you like to do?
debounce function for dart
library debounce;
Map timeouts = {};
void debounce(int timeoutMS, Function target, List arguments) {
if(timeouts.containsKey(target)) {
Timer timer = new Timer(new Duration(milliseconds: timeoutMS), () {
Function.apply(target, arguments);
timeouts[target] = timer;
void saveWord(Word word) { ... }
debounce(800, saveWord, [word]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.