Skip to content

Instantly share code, notes, and snippets.

@garth
Last active March 16, 2016 20:26
Show Gist options
  • Save garth/c1ff94b9cb41ad1b107d to your computer and use it in GitHub Desktop.
Save garth/c1ff94b9cb41ad1b107d to your computer and use it in GitHub Desktop.
cerebral-addons: calling debounce() without options has been temporarily deprecated.

before v0.6.x

The current default implementation of debounce is actually closer to throttle. We plan to transition the current behaviour to throttle, and change the deault behavour of debounce in the next major release.

Until version 0.6.x is released the following will give a deprecation warning:

signal('fieldChanged', [
  copy('input:/value', 'state:/form.field'),
  debounce(500, [
    validateForm
  ])
]);

To remove the warning but keep the current behaviour, simple add the options which define the current default behaviour:

signal('fieldChanged', [
  copy('input:/value', 'state:/form.field'),
  debounce(500, [
    validateForm
  ], { immediate: true, throttle: true }) // <- current defaults for version 0.5.x
]);

Even better would be to move to the new throttle() action factory.

after v0.6.x

The default behaviour of throttle will become:

signal('fieldChanged', [
  copy('input:/value', 'state:/form.field'),
  debounce(500, [
    validateForm
  ], { immediate: false, throttle: false })
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment