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.26.8 app/packs/src/decidim/delayed.js
decidim-core-0.27.4 app/packs/src/decidim/delayed.js
decidim-core-0.27.3 app/packs/src/decidim/delayed.js
decidim-core-0.26.7 app/packs/src/decidim/delayed.js
decidim-core-0.26.5 app/packs/src/decidim/delayed.js
decidim-core-0.27.2 app/packs/src/decidim/delayed.js
decidim-core-0.27.1 app/packs/src/decidim/delayed.js
decidim-core-0.26.4 app/packs/src/decidim/delayed.js
decidim-core-0.27.0 app/packs/src/decidim/delayed.js
decidim-core-0.26.3 app/packs/src/decidim/delayed.js
decidim-core-0.27.0.rc2 app/packs/src/decidim/delayed.js
decidim-core-0.27.0.rc1 app/packs/src/decidim/delayed.js
decidim-core-0.26.2 app/packs/src/decidim/delayed.js
decidim-core-0.26.1 app/packs/src/decidim/delayed.js
decidim-core-0.26.0 app/packs/src/decidim/delayed.js
decidim-core-0.26.0.rc2 app/packs/src/decidim/delayed.js
decidim-core-0.26.0.rc1 app/packs/src/decidim/delayed.js
decidim-core-0.25.2 app/packs/src/decidim/delayed.js
decidim-core-0.25.1 app/packs/src/decidim/delayed.js
decidim-core-0.25.0 app/packs/src/decidim/delayed.js