Bladeren bron

Add doc strings and export `Debouncer`.

Afshin T. Darian 6 jaren geleden
bovenliggende
commit
aa79d265df
1 gewijzigde bestanden met toevoegingen van 20 en 1 verwijderingen
  1. 20 1
      packages/coreutils/src/poll.ts

+ 20 - 1
packages/coreutils/src/poll.ts

@@ -549,20 +549,39 @@ export namespace Poll {
   export const MAX_INTERVAL = 2147483647;
 }
 
-class Debouncer extends Poll<void, void> {
+/**
+ * A poll that only schedules ticks manually.
+ */
+export class Debouncer extends Poll<void, void> {
+  /**
+   * Instantiate a debouncer poll.
+   *
+   * @param factory - The poll factory.
+   *
+   * @param interval - The debounce interval.
+   */
   constructor(factory: Poll.Factory<void, void>, public interval: number) {
     super({ factory, name: 'DEBOUNCER' });
     void super.stop();
   }
 
+  /**
+   * The debouncer frequency.
+   */
   readonly frequency: IPoll.Frequency = {
     backoff: false,
     interval: Infinity,
     max: Infinity
   };
 
+  /**
+   * The debouncer poll standby value.
+   */
   readonly standby = 'when-hidden';
 
+  /**
+   * Debounce a request to refresh the poll within the debounce interval.
+   */
   async debounce(): Promise<void> {
     await this.schedule({
       cancel: last => last.phase === 'refreshed',