本文整理汇总了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);