當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript kernel.PLATFORM.global類代碼示例

本文整理匯總了TypeScript中@aurelia/kernel.PLATFORM.global的典型用法代碼示例。如果您正苦於以下問題:TypeScript PLATFORM.global類的具體用法?TypeScript PLATFORM.global怎麽用?TypeScript PLATFORM.global使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PLATFORM.global類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: throttle

export function throttle(this: ThrottleableBinding, newValue: unknown): void {
  const state = this.throttleState;
  const elapsed = +new Date() - state.last;

  if (elapsed >= state.delay) {
    PLATFORM.global.clearTimeout(state.timeoutId);
    state.timeoutId = -1;
    state.last = +new Date();
    this.throttledMethod(newValue);
    return;
  }

  state.newValue = newValue;

  if (state.timeoutId === -1) {
    const timeoutId = PLATFORM.global.setTimeout(
      () => {
        state.timeoutId = -1;
        state.last = +new Date();
        this.throttledMethod(state.newValue);
      },
      state.delay - elapsed
    );
    state.timeoutId = timeoutId;
  }
}
開發者ID:aurelia,項目名稱:aurelia,代碼行數:26,代碼來源:throttle.ts

示例2: unbind

 public unbind(flags: LifecycleFlags, scope: IScope, binding: DebounceableBinding): void {
   // restore the state of the binding.
   const methodToRestore = binding.debouncedMethod.originalName;
   binding[methodToRestore] = binding.debouncedMethod;
   binding.debouncedMethod = null;
   PLATFORM.global.clearTimeout(binding.debounceState.timeoutId);
   binding.debounceState = null;
 }
開發者ID:aurelia,項目名稱:aurelia,代碼行數:8,代碼來源:debounce.ts

示例3: debounceCall

export function debounceCall(this: DebounceableBinding, newValue: unknown, oldValue: unknown, flags: LifecycleFlags): void {
  const state = this.debounceState;
  PLATFORM.global.clearTimeout(state.timeoutId);
  if (!(flags & state.callContextToDebounce)) {
    state.oldValue = unset;
    this.debouncedMethod(newValue, oldValue, flags);
    return;
  }
  if (state.oldValue === unset) {
    state.oldValue = oldValue;
  }
  const timeoutId = PLATFORM.global.setTimeout(
    () => {
      const ov = state.oldValue;
      state.oldValue = unset;
      this.debouncedMethod(newValue, ov, flags);
    },
    state.delay
  );
  state.timeoutId = timeoutId;
}
開發者ID:aurelia,項目名稱:aurelia,代碼行數:21,代碼來源:debounce.ts

示例4: debounceCallSource

export function debounceCallSource(this: DebounceableBinding, newValue: unknown, oldValue: unknown, flags: LifecycleFlags): void {
  const state = this.debounceState;
  PLATFORM.global.clearTimeout(state.timeoutId);
  state.timeoutId = PLATFORM.global.setTimeout(() => { this.debouncedMethod(newValue, oldValue, flags); }, state.delay);
}
開發者ID:aurelia,項目名稱:aurelia,代碼行數:5,代碼來源:debounce.ts

示例5: Promise

 return new Promise((resolve: ITimerHandler) => PLATFORM.global.setTimeout(resolve, !isNaN(delay) ? delay : 0))
開發者ID:aurelia,項目名稱:aurelia,代碼行數:1,代碼來源:retry-interceptor.ts


注:本文中的@aurelia/kernel.PLATFORM.global類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。