'Debounce a refresh button in VSCode extension

So my issue is that I would like to wrap a refreshing function for the treeview in a debounce so the user wont be able to make a lot of calls by clicking too fast. What I have is this function:

  async refresh(isButton: boolean): Promise<void> {
...
    providersSingleton.load(loadedItems);
    MyTreeProvider.onDidChangeTreeDataEmitter.fire();
    ..
  }

The thing is refresh() button isn't called anywhere else accessible for me so I can't just wrap it in a _.debounce. How can I debounce say 20 clicks in a second?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source