Sha256: 5ef5dbc048fc083c87c750056139a460ce9514875df3e6a6a834859d47a5a68d

Contents?: true

Size: 717 Bytes

Versions: 44

Compression:

Stored size: 717 Bytes

Contents

/**
 * Returns a function, that, as long as it continues to be invoked, will not
 * be triggered. The function will be called after it stops being called for
 * N milliseconds.
 * @param {Object} context - the context for the called function.
 * @param {Function} func - the function to be executed.
 * @param {int} wait - number of milliseconds to wait before executing the function.
 * @private
 * @returns {Void} - Returns nothing.
 */
export default function delayed(context, func, wait) {
  let timeout = null;

  return function(...args) {
    if (timeout) {
      clearTimeout(timeout);
    }
    timeout = setTimeout(() => {
      timeout = null;
      Reflect.apply(func, context, args);
    }, wait);
  }
}

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/packs/src/decidim/delayed.js
decidim-core-0.28.4 app/packs/src/decidim/delayed.js
decidim-core-0.27.9 app/packs/src/decidim/delayed.js
decidim-core-0.29.0 app/packs/src/decidim/delayed.js
decidim-core-0.28.3 app/packs/src/decidim/delayed.js
decidim-core-0.27.8 app/packs/src/decidim/delayed.js
decidim-core-0.29.0.rc4 app/packs/src/decidim/delayed.js
decidim-core-0.29.0.rc3 app/packs/src/decidim/delayed.js
decidim-core-0.29.0.rc2 app/packs/src/decidim/delayed.js
decidim-core-0.29.0.rc1 app/packs/src/decidim/delayed.js
decidim-core-0.28.2 app/packs/src/decidim/delayed.js
decidim-core-0.27.7 app/packs/src/decidim/delayed.js
decidim-core-0.28.1 app/packs/src/decidim/delayed.js
decidim-core-0.27.6 app/packs/src/decidim/delayed.js
decidim-core-0.26.10 app/packs/src/decidim/delayed.js
decidim-core-0.26.9 app/packs/src/decidim/delayed.js
decidim-core-0.28.0 app/packs/src/decidim/delayed.js
decidim-core-0.27.5 app/packs/src/decidim/delayed.js
decidim-core-0.28.0.rc5 app/packs/src/decidim/delayed.js
decidim-core-0.28.0.rc4 app/packs/src/decidim/delayed.js