本文整理汇总了TypeScript中d3-timer.timeout函数的典型用法代码示例。如果您正苦于以下问题:TypeScript timeout函数的具体用法?TypeScript timeout怎么用?TypeScript timeout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了timeout函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: measureOnce
export function measureOnce(sec: number, drawFPS: (fps: string) => void) : void {
let ctr = 0
timer(() => ctr++)
timeout(() => {
drawFPS((ctr / sec).toPrecision(3))
ctr = 0
}, 1000 * sec)
}
开发者ID:streamcode9,项目名称:svg-time-series,代码行数:10,代码来源:measure.ts
示例2:
// Test now definition
const now: number = d3Timer.now();
// Test timer and timerFlush definitions ------------
let t0: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); });
let t1: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150);
let t2: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.restart((elapsed: number) => { console.log(elapsed); });
t0.restart((elapsed: number) => { console.log(elapsed); }, 150);
t0.restart((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.stop();
d3Timer.timerFlush();
t1.stop(); t2.stop();
// Test timeout Timer definitions --------------------------------
t0 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); });
t1 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); }, 150);
t2 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
// Test interval Timer definitions --------------------------------
t0 = d3Timer.interval((elapsed: number) => { console.log(elapsed); });
t1 = d3Timer.interval((elapsed: number) => { console.log(elapsed); }, 150);
t2 = d3Timer.interval((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:29,代码来源:d3-timer-tests.ts
示例3:
return (...params: any[]) => {
if (!requested) {
requested = true
runTimeout((elapsed: number) => {
requested = false
f(params)
})
}
}
开发者ID:streamcode9,项目名称:svg-time-series,代码行数:9,代码来源:draw.ts
注:本文中的d3-timer.timeout函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论