本文整理匯總了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;
}
}
示例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;
}
示例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;
}
示例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);
}
示例5: Promise
return new Promise((resolve: ITimerHandler) => PLATFORM.global.setTimeout(resolve, !isNaN(delay) ? delay : 0))