Debouncing in TypeScript, v2

This is a follow-up article to my previous one, Debouncing in TypeScript. It will be straight to the point about the revisions.

Mild changes to the previous version.

A couple household updates include:

  • Constructor doesn’t have a return type
  • Setting lastTrigger in constructor to avoid immediate execution

More significant updates include:

You can use this class in this way:

The core piece here is the Debounce.exec(..., );

This example assumes that you have a symbol defined for each class instantiation which will provide a unique namespace for every Debounce instance. If you continually create new symbols, it will make new instances per call.

--

--

Chief Product Engineer. Frontend, Backend, Systems, Electronics, 3D Printing, Photography.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Matt Kenefick

Chief Product Engineer. Frontend, Backend, Systems, Electronics, 3D Printing, Photography.