当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.throttle类代码示例

本文整理汇总了TypeScript中lodash.throttle的典型用法代码示例。如果您正苦于以下问题:TypeScript throttle类的具体用法?TypeScript throttle怎么用?TypeScript throttle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了throttle类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: renderHtml

 cursor.each(() => {
     
      renderHtml()
     throttle(()=>{
        console.log('throttle')
     }, 5000, {leading:true})
 })
开发者ID:HelixOne,项目名称:leto,代码行数:7,代码来源:server.ts

示例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))
}
开发者ID:goblindegook,项目名称:littlefoot,代码行数:20,代码来源:events.ts

示例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;
    };
}
开发者ID:emonkak,项目名称:feedpon,代码行数:41,代码来源:saveStateMiddleware.ts

示例4: bindContentScrollHandler

export function bindContentScrollHandler(contentElement: Element): void {
  const throttledScrollHandler = throttle<EventHandler<any>>(scrollHandler)
  contentElement.addEventListener('mousewheel', throttledScrollHandler)
  contentElement.addEventListener('wheel', throttledScrollHandler)
}
开发者ID:goblindegook,项目名称:littlefoot,代码行数:5,代码来源:events.ts


注:本文中的lodash.throttle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。