本文整理汇总了TypeScript中rxjs/observable/timer.timer函数的典型用法代码示例。如果您正苦于以下问题:TypeScript timer函数的具体用法?TypeScript timer怎么用?TypeScript timer使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了timer函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: switchMap
switchMap(([event, options, element, document]) => {
return timer(event[1] || 2000).pipe(
tap(() => {
element.style.display = "none";
if (element.parentNode) {
document.body.removeChild(element);
}
})
);
})
示例2: mergeMap
, mergeMap(() => {
return timer(200).pipe(
tap(() => {
// if another reattachImportedRule call is in progress, abandon this one
if (rule.__LiveReload_newHref !== href) { return; }
parent.insertRule(newRule, index);
return parent.deleteRule(index+1);
})
)
})
示例3: playPhrase
playPhrase(start: number, duration: number) {
console.log('In video playPhrase, start=' + start + ' duration=' + duration);
// const timer = Observable.timer(duration * 1000);
const timerx = timer(100); // yield for 100 milliseconds
timerx.subscribe(t => this.api.pause());
// timer.subscribe(t=>console.log('done with timeout'));
this.api.seekTime(start);
this.api.play();
console.log('exiting video playPhrase');
}
示例4: reattachImportedRule
function reattachImportedRule({ rule, index, link }, document: Document): Observable<any> {
const parent = rule.parentStyleSheet;
const href = generateCacheBustUrl(rule.href);
const media = rule.media.length ? [].join.call(rule.media, ', ') : '';
const newRule = `@import url("${href}") ${media};`;
// used to detect if reattachImportedRule has been called again on the same rule
rule.__LiveReload_newHref = href;
// WORKAROUND FOR WEBKIT BUG: WebKit resets all styles if we add @import'ed
// stylesheet that hasn't been cached yet. Workaround is to pre-cache the
// stylesheet by temporarily adding it as a LINK tag.
const tempLink = document.createElement("link");
tempLink.rel = 'stylesheet';
tempLink.href = href;
tempLink.__LiveReload_pendingRemoval = true; // exclude from path matching
if (link.parentNode) {
link.parentNode.insertBefore(tempLink, link);
}
return timer(200)
.pipe(
tap(() => {
if (tempLink.parentNode) { tempLink.parentNode.removeChild(tempLink); }
// if another reattachImportedRule call is in progress, abandon this one
if (rule.__LiveReload_newHref !== href) { return; }
parent.insertRule(newRule, index);
parent.deleteRule(index+1);
// save the new rule, so that we can detect another reattachImportedRule call
rule = parent.cssRules[index];
rule.__LiveReload_newHref = href;
})
, mergeMap(() => {
return timer(200).pipe(
tap(() => {
// if another reattachImportedRule call is in progress, abandon this one
if (rule.__LiveReload_newHref !== href) { return; }
parent.insertRule(newRule, index);
return parent.deleteRule(index+1);
})
)
})
);
}
示例5: switchMap
switchMap(() => {
return concat(of(false), timer(timeout).pipe(mapTo(true)));
}),
示例6: return
return (c: AbstractControl) => { return map.call(timer(time), () => errorMap); };
示例7: timer
(() => {
console.log("Starting count down:");
timer(0, 1000).pipe(map(n => 5 - n), take(6)).subscribe(n => console.log(n));
}); //();
示例8: spyOn
spyOn(translate.currentLoader, 'getTranslation').and.callFake(() => {
getTranslationCalls += 1;
return timer(1000).pipe(mapTo(of(translations)));
});