本文整理匯總了TypeScript中rxjs.AsyncSubject類的典型用法代碼示例。如果您正苦於以下問題:TypeScript AsyncSubject類的具體用法?TypeScript AsyncSubject怎麽用?TypeScript AsyncSubject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了AsyncSubject類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: asyncSubject
asyncSubject() {
let asyncSubject$ = new AsyncSubject();
interval(300).pipe(
take(5)
)
.subscribe(asyncSubject$);
asyncSubject$.subscribe(val => console.log(`First async subject: ${val}`)); // 4 (only after 1.5sec)
// Subscribe after it will complete
setTimeout(() => {
asyncSubject$.subscribe(val => console.log(`Second async subject: ${val}`)) // 4
}, 2000);
}
示例2: setInterval
var handle = setInterval(function () {
subject.next(i);
if (++i > 3) {
subject.complete();
clearInterval(handle);
}
}, 500);
示例3: setTimeout
setTimeout(() => {
asyncSubject$.subscribe(val => console.log(`Second async subject: ${val}`)) // 4
}, 2000);