Skip to content

Instantly share code, notes, and snippets.

@weargoggles
Last active June 6, 2016 11:01
Show Gist options
  • Save weargoggles/1ea72b72d5dca4d63f468279059a168b to your computer and use it in GitHub Desktop.
Save weargoggles/1ea72b72d5dca4d63f468279059a168b to your computer and use it in GitHub Desktop.
const (action_type, delay) => store => next => {
let last = performance.now() - delay;
return action => {
let now;
if (action.type === action_type) {
now = performance.now();
if (now - last > delay) {
last = now;
return next(action);
} else {
return null;
}
}
return next(action);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment