How to use the debounce function in debounce

To help you get started, we’ve selected a few debounce 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 post-tracker / site / app / actions.js View on Github external
} catch ( postsFail ) {
                dispatch( receivePosts( [] ) );
                console.error( postsFail );
            }
        } );
    } );

    request.on( 'error', ( requestError ) => {
        // eslint-disable-next-line no-console
        console.error( `problem with request: ${ requestError.message }` );
    } );

    request.end();
};

const debouncedFetchPosts = debounce( getPosts, FETCH_DEBOUNCE_INTERVAL );

const fetchPosts = function fetchPosts ( state ) {
    const {
        search,
        groups,
        services,
     } = state;

    return ( dispatch ) => {
        debouncedFetchPosts( search, groups, services, dispatch );
    };
};

const fetchPostsImmediate = function fetchPostsImmediate ( state ) {
    const {
        search,
github zubairghori / Ultimate_todo_list / react-todo-rest-api / node_modules / @material-ui / core / es / Slide / Slide.js View on Github external
constructor(...args) {
    super(...args);
    this.mounted = false;
    this.handleResize = debounce(() => {
      // Skip configuration where the position is screen size invariant.
      if (this.props.in || this.props.direction === 'down' || this.props.direction === 'right') {
        return;
      }

      if (this.transitionRef) {
        setTranslateValue(this.props, this.transitionRef);
      }
    }, 166);

    this.handleEnter = node => {
      setTranslateValue(this.props, node);
      reflow(node);

      if (this.props.onEnter) {
        this.props.onEnter(node);
github buttercup / buttercup-browser-extension / source / shared / library / mouseEvents.js View on Github external
export function trackScrolling() {
    const debouncedUserActivity = debounce(() => trackUserActivity(), 250, /* trailing: */ false);
    const handleScrollUpdate = () => {
        debouncedUserActivity();
    };
    window.addEventListener("scroll", handleScrollUpdate);
}
github vtex-apps / store-components / react / components / ProductDescription / components / GradientCollapse.js View on Github external
this.state = { isCollapseVisible: true, collapsed: true, maxHeight: 'auto' }

    this.wrapper = React.createRef()
  }

  calcMaxHeight = () => {
    const { collapseHeight } = this.props
    const wrapper = this.wrapper.current

    if (wrapper.scrollHeight > collapseHeight) {
      const maxHeight = wrapper.scrollHeight + 60
      this.setState({ isCollapseVisible: true, maxHeight })
    } else this.setState({ isCollapseVisible: false, maxHeight: 'auto' })
  }

  debouncedCalcMaxHeight = debounce(this.calcMaxHeight, 500)

  componentDidMount() {
    window.addEventListener('resize', this.debouncedCalcMaxHeight)
    this.calcMaxHeight()
  }

  componentWillUnmount() {
    window.removeEventListener('resize', this.debouncedCalcMaxHeight)
  }

  render() {
    const { children, collapseHeight } = this.props
    const { collapsed, isCollapseVisible, maxHeight } = this.state
    const height = isCollapseVisible && collapsed ? collapseHeight : maxHeight
    const transitionTime = 600
    const fadeOutTime = 400
github awethemes / awebooking / assets / babel / admin / admin.js View on Github external
awebooking.dialog = function (selector) {
  const $dialog = $(selector).dialog({
    modal: true,
    width: 'auto',
    height: 'auto',
    autoOpen: false,
    draggable: false,
    resizable: false,
    closeOnEscape: true,
    dialogClass: 'wp-dialog awebooking-dialog',
    position: { my: 'center', at: 'center center-15%', of: window },
  })

  $(window).on('resize', debounce(() => {
    $dialog.dialog('option', 'position', { my: 'center', at: 'center center-15%', of: window })
  }, 150))

  return $dialog
}
github devfake / flox / client / app / components / Content / Settings / Reminders.vue View on Github external
created() {
      this.fetchUserData();
      this.clearSuccessMessage = debounce(this.clearSuccessMessage, debounceMilliseconds);
    },
github kvartborg / hueify / src / views / Lights.jsx View on Github external
<span>
            
            <span>
              {light.name}
            </span>
          </span>
          
        
      
    )
  }
}
github odopod / code-library / packages / odo-base-component / src / base-component.js View on Github external
_registerMediaQueryListeners() {
    this._onMediaChange = debounce(this.onMediaQueryChange.bind(this), 50);
    Object.keys(BaseComponent.queries).forEach((k) => {
      BaseComponent.queries[k].addListener(this._onMediaChange);
    });
  }
github planttheidea / react-windowed-list / src / instanceMethods.js View on Github external
return () => {
    const {debounceReconciler} = instance.props;

    instance.reconcileFrameAfterUpdate = isNumber(debounceReconciler)
      ? debounce((updateFrame) => {
        updateFrame();
      }, debounceReconciler)
      : raf;
  };
};
github razee-io / Razeedash / imports / ui / pages / resources / index.js View on Github external
$from.datepicker({
        autoclose: true,
        container: '#datepickersContainer',
    });
    $to.datepicker({
        autoclose: true,
        container: '#datepickersContainer',
        useCurrent: false,
    });
    showDatepickers.set(fromTime || toTime);

    this.find('input').focus();
});

const debounceSubscription = debounce( ( instance, fromTime, toTime )=> {
    instance.subscribe('resourcesSearch', Session.get('currentOrgId'), getStoredQ(), displayLimit.get(), fromTime, toTime);
}, 500);

Template.page_resources.onCreated(function() {
    this.autorun(() => {
        var urlQ = FlowRouter.getQueryParam('q') || '';
        var urlLimit = parseInt(FlowRouter.getQueryParam('limit') || 0);

        if (urlQ && getStoredQ != urlQ) {
            setStoredQ(urlQ);
        }

        if (urlLimit && displayLimit.get() != urlLimit) {
            displayLimit.set(urlLimit);
            return;
        }

debounce

Delay function calls until a set time elapses after the last invocation

MIT
Latest version published 5 months ago

Package Health Score

84 / 100
Full package analysis

Popular debounce functions