wx-throttle-debounce

1.0.6 • Public • Published

wx-throttle-debounce

🙌 Throttle & Debounce functions for Wechat MiniProgram

Usage

npm i -S wx-throttle-debounce --production

Doc

debounce(func, wait, options)

Arguments

func (Function): The function to debounce.

[wait=0] (number): The number of milliseconds to delay.

[options={}] (Object): The options object.

[options.leading=false] (boolean): Specify invoking on the leading edge of the timeout.

[options.maxWait] (number): The maximum time func is allowed to be delayed before it's invoked.

[options.trailing=true] (boolean): Specify invoking on the trailing edge of the timeout.

Return

(Function): Returns the new debounced function.

throttle(func, wait, options)

Arguments

func (Function): The function to throttle.

[wait=0] (number): The number of milliseconds to throttle invocations to.

[options={}] (Object): The options object.

[options.leading=true] (boolean): Specify invoking on the leading edge of the timeout.

[options.trailing=true] (boolean): Specify invoking on the trailing edge of the timeout.

Return

(Function): Returns the new throttled function.

Example

import { debounce, throttle } from 'wx-throttle-debounce';

Page({
  ...
  debouncedFunc: debounce(function(events) {
    // do somthing
  }, 100, { /* some options */ }),
  throttledFunc: throttle(function(events) {
    // do somthing
  }, 100, { /* some options */ }),
  ...
});

Readme

Keywords

Package Sidebar

Install

npm i wx-throttle-debounce

Weekly Downloads

0

Version

1.0.6

License

ISC

Unpacked Size

23.5 kB

Total Files

12

Last publish

Collaborators

  • chrischan