Skip to content

ChrisChan13/wx-throttle-debounce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

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 */ }),
  ...
});

About

๐Ÿ™Œ Throttle & Debounce functions for Wechat MiniProgram

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published