本文整理匯總了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)));
});