chore: refactor swap component to use useSwap hook chore: mock redux store for use in storybook chore: update mocked state chore: rename test files to .tsx chore(wallet): mock lib and bridge fix(wallet): prevent state updates after unmount fix: prevent swap state updates after unmount chore: refactor WalletApiProxy mock chore: mock api response fix: hoist swap state to appropriate level chore(wallet): remove debugging logs & alerts chore(wallet): remove unused factory chore: extract useIsMounted hook docs: add comment about useEffect cleanup chore: organize imports chore: rearrange imports chore: refactor isMounted hook response fix: unspread swap props chore: fix broken tests chore: use two spaces for indentation
18 lines
587 B
TypeScript
18 lines
587 B
TypeScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
'use strict'
|
|
|
|
export const debounce = function <T>(fn: (data: T) => void, bufferInterval: number, ...args: any[]) {
|
|
let timeout: any
|
|
return (...args2: any[]) => {
|
|
clearTimeout(timeout)
|
|
let a: string[] = args || []
|
|
if (args2 && args2.constructor === Array) {
|
|
a = a.concat(args2)
|
|
}
|
|
timeout = setTimeout(fn.apply.bind(fn, this, a), bufferInterval)
|
|
}
|
|
}
|