How to use just-debounce-it - 10 common examples

To help you get started, we’ve selected a few just-debounce-it examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github therehq / there-desktop / renderer / components / edit / Person / Person.js View on Github external
locationPicked = ({ placeId, timezone }) => {
    this.setState({ placeId, timezone, notFilled: false })
  }

  photoModeChanged = photoMode => {
    this.setState({ photoMode })
  }

  twitterChanged = e => {
    const twitterHandle = e.target.value
    this.setState({ twitterHandle })
    // Fetch avatar in the background
    this.getAvatar(twitterHandle)
  }

  getAvatar = debounce(async twitter => {
    if (typeof window === 'undefined' || !twitter) {
      this.setState({ photoUrl: '', photoCloudObject: null })
      return
    }

    const result = await fetch(`${restEndpoint}/twivatar/${twitter}`)

    // Image not found
    if (!result.ok) {
      this.setState({ photoUrl: '', photoCloudObject: null })
      return
    }

    this.setState({
      photoUrl: `${restEndpoint}/twivatar/${twitter}`,
      photoCloudObject: null,
github palmerhq / changecast / site / src / templates / ReleaseTemplate.js View on Github external
function getReleaseSearch() {
    if (search.current !== null) {
      return search.current
    }

    const debouncedMark = debounce(value => {
      if (mark.current) {
        mark.current.unmark()
      }
      mark.current = new Mark(document.querySelectorAll('.release'))
      mark.current.mark(value)
    }, 100)

    search.current = value => {
      setSearchValue(value)
      debouncedMark(value)
    }

    return search.current
  }
github JetBrains / ring-ui / components / place-under-ng / place-under-ng.js View on Github external
function syncPositionWith(syncElement) {
        removeScrollListeners();

        const afterScrollFinishRecheck =
          debounce(() => this.onScroll(syncElement), AFTER_SCROLL_RECHECK_INTERVAL);

        const sidebarScrollListener = debounce(() => {
          this.onScroll(syncElement);
          afterScrollFinishRecheck();
        }, DEBOUNCE_INTERVAL);

        this.waitForNonZeroHeight(syncElement).then(sidebarScrollListener);

        $window.addEventListener('scroll', sidebarScrollListener);
        removeScrollListener.push(() => {
          $window.removeEventListener('scroll', sidebarScrollListener);
        });


        removeScrollListener.push(scope.$watch('show', sidebarScrollListener));
        removeScrollListener.push(scope.$on('rgPlaceUnder:sync', sidebarScrollListener));
github palmerhq / changecast / site / src / templates / ReleasesTemplate.js View on Github external
if (search.current !== null) {
      return search.current
    }
    const releaseSearch = new Search(['node', 'id'])
    releaseSearch.searchIndex = new UnorderedSearchIndex()
    releaseSearch.addIndex(['node', 'name'])
    releaseSearch.addIndex(['node', 'tagName'])
    releaseSearch.addIndex([
      'node',
      'childGithubReleaseBody',
      'childMarkdownRemark',
      'plainText',
    ])
    releaseSearch.addDocuments(edges)

    const debouncedReleaseSearch = debounce(value => {
      setReleases(!!value ? releaseSearch.search(value) : edges)
    }, 100)

    search.current = value => {
      setSearchValue(value)
      debouncedReleaseSearch(value)
    }

    return search.current
  }
github JetBrains / ring-ui / components / query-assist / query-assist.js View on Github external
setupRequestHandler(delay) {
    const needDelay = typeof delay === 'number';
    const hasDelay = this.requestData !== this.requestHandler;

    if (!this.requestData || hasDelay !== needDelay) {
      if (needDelay) {
        this.requestData = debounce(this.requestHandler, delay);
      } else {
        this.requestData = this.requestHandler;
      }
    }
  }
github SUI-Components / sui / packages / sui-studio / src / components / demo / CodeEditor.js View on Github external
const createOnChangeDebounced = () => {
    return debounce((codeMirrorDocument, change) => {
      if (change !== 'setValue') {
        onChange(codeMirrorDocument.getValue())
      }
    }, DEBOUNCE_TIME)
  }
github fanfoujs / space-fanfou / src / features / go-top-button / @page.js View on Github external
if (existingButton) existingButton.remove()
    container.append(toTopButton)
    hideButton()

    return toTopButton
  }

  function clickHandler(event) {
    event.preventDefault()

    hideButton()
    animatedScrollTop()
  }

  const debouncedScrollHandler = debounce(() => {
    if (scrollManager.getScrollTop() > MAIN_TOP) {
      showButton()
    } else {
      hideButton()
    }
  }, SCROLL_DEBOUNCE_WAIT)

  function scrollHandler() {
    hideButton()
    debouncedScrollHandler()
  }

  function showButton() {
    if (!isHidden) return
    isHidden = false
github JetBrains / ring-ui / components / place-under-ng / place-under-ng.js View on Github external
function syncPositionWith(syncElement) {
        removeScrollListeners();

        const afterScrollFinishRecheck =
          debounce(() => this.onScroll(syncElement), AFTER_SCROLL_RECHECK_INTERVAL);

        const sidebarScrollListener = debounce(() => {
          this.onScroll(syncElement);
          afterScrollFinishRecheck();
        }, DEBOUNCE_INTERVAL);

        this.waitForNonZeroHeight(syncElement).then(sidebarScrollListener);

        $window.addEventListener('scroll', sidebarScrollListener);
        removeScrollListener.push(() => {
          $window.removeEventListener('scroll', sidebarScrollListener);
        });


        removeScrollListener.push(scope.$watch('show', sidebarScrollListener));
        removeScrollListener.push(scope.$on('rgPlaceUnder:sync', sidebarScrollListener));
github JetBrains / ring-ui / components / table-legacy-ng / table-legacy-ng.js View on Github external
scope.stickToSelector = iAttrs.stickTo;

        //Shortcut for placing under table toolbar
        if (iAttrs.stickToToolbar !== undefined) {
          scope.stickToSelector = '.ring-table__toolbar';
        }

        const scrollableHeader = element.querySelector('.ring-table__header:not(.ring-table__header_sticky)');
        const fixedHeader = element.querySelector('.ring-table__header_sticky');

        const toolbarFixed = () => stickToElement.querySelector(`.${TOOLBAR_FIXED_CLASSNAME}`) !== null;

        /**
         * Sync header columns width with real table
         */
        const resizeFixedHeader = debounce(() => {
          fixedHeader.style.width = `${scrollableHeader.offsetWidth}px`;
          const titles = [...fixedHeader.querySelectorAll('.ring-table__title')];

          titles.forEach((titleElement, index) => {
            const targetHeaderTitle =
              scrollableHeader.querySelectorAll('.ring-table__title')[index];
            titleElement.style.width = getStyles(targetHeaderTitle).width;
          });

        }, HEADER_RESIZE_DEBOUNCE, true);

        /**
         * Toggle headers on scroll. Also resize header columns with some big interval
         */
        const scrollListener = debounce(() => {
          if (toolbarFixed()) {
github fanfoujs / space-fanfou / src / features / auto-pager / @page.js View on Github external
export default context => {
  const { requireModules, elementCollection } = context
  const { scrollManager } = requireModules([ 'scrollManager' ])

  const onScroll = debounce(() => {
    if (!hasReachedBottom()) return
    if (isLoading()) return
    if (!isButtonVisible()) return

    loadMore()
  }, SCROLL_DEBOUNCE_WAIT)

  elementCollection.add({
    buttonMore: '#pagination-more',
  })

  function loadMore() {
    elementCollection.get('buttonMore').click()
  }

  function hasReachedBottom() {

just-debounce-it

return a debounced function

MIT
Latest version published 2 years ago

Package Health Score

64 / 100
Full package analysis

Popular just-debounce-it functions