本文整理汇总了TypeScript中lodash.throttle.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript throttle.default方法的具体用法?TypeScript throttle.default怎么用?TypeScript throttle.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lodash.throttle
的用法示例。
在下文中一共展示了throttle.default方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: renderHtml
cursor.each(() => {
renderHtml()
throttle(()=>{
console.log('throttle')
}, 5000, {leading:true})
})
示例2: bindEvents
export function bindEvents({
dismissAll,
get,
hover,
reposition,
resize,
toggle,
unhover
}: Core): void {
document.addEventListener('touchend', handleTap(get, toggle, dismissAll))
document.addEventListener('click', handleTap(get, toggle, dismissAll))
document.addEventListener('keyup', handleEscape(dismissAll))
document.addEventListener('gestureend', throttle(reposition))
window.addEventListener('scroll', throttle(reposition))
window.addEventListener('resize', throttle(resize))
on('mouseover', `[${FOOTNOTE_BUTTON_ID}]`, handleHover(get, hover))
on('mouseout', `[${FOOTNOTE_BUTTON_ID}]`, handleHover(get, unhover))
on('mouseout', `[${FOOTNOTE_POPOVER_ID}]`, handleHover(get, unhover))
}
示例3: async
function saveStateMiddlewareFactory<TState, TEvent>(save: (state: any) => Promise<void>, saveInterval: number): Middleware<TState, TEvent> {
let promise = Promise.resolve();
let changes: Partial<TState> = {};
let numChanges = 0;
const saveChanges = async () => {
try {
await promise;
} finally {
if (numChanges > 0) {
const savingChanges = changes;
changes = {};
numChanges = 0;
promise = save(savingChanges);
}
}
};
const processChanges = throttle(throttleIdleCallback(saveChanges), saveInterval);
return ({ getState }) => (event, next) => {
const state = getState();
const result = next(event);
const nextState = getState();
for (const key in state) {
if (state[key] !== nextState[key]) {
changes[key] = nextState[key];
numChanges++;
}
}
if (numChanges > 0) {
processChanges();
}
return result;
};
}
示例4: bindContentScrollHandler
export function bindContentScrollHandler(contentElement: Element): void {
const throttledScrollHandler = throttle<EventHandler<any>>(scrollHandler)
contentElement.addEventListener('mousewheel', throttledScrollHandler)
contentElement.addEventListener('wheel', throttledScrollHandler)
}