本文整理汇总了TypeScript中rxjs/operators.repeatWhen函数的典型用法代码示例。如果您正苦于以下问题:TypeScript repeatWhen函数的具体用法?TypeScript repeatWhen怎么用?TypeScript repeatWhen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了repeatWhen函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should unsubscribe scheduled actions after execution', () => {
let subscribeSpy: any = null;
const counts: number[] = [];
const e1 = cold('a|');
const expected = '--a-(a|)';
const duration = time('-|');
const result = e1.pipe(
repeatWhen(notifications => {
const delayed = notifications.pipe(delay(duration, rxTestScheduler));
subscribeSpy = sinon.spy(delayed['source'], 'subscribe');
return delayed;
}),
skip(1),
take(2),
tap({
next() {
const [[subscriber]] = subscribeSpy.args;
counts.push(subscriber._subscriptions.length);
},
complete() {
expect(counts).to.deep.equal([1, 1]);
}
})
);
expectObservable(result).toBe(expected);
});
开发者ID:tomastrajan,项目名称:rxjs,代码行数:28,代码来源:delay-spec.ts
示例2: higherOrder
export function repeatWhen<T>(this: Observable<T>, notifier: (notifications: Observable<any>) => Observable<any>): Observable<T> {
return higherOrder(notifier)(this) as Observable<T>;
}
开发者ID:DallanQ,项目名称:rxjs,代码行数:3,代码来源:repeatWhen.ts
示例3: Symbol
// @ts-ignore
import { stream } from "@dcos/mesos-client";
import { timer } from "rxjs";
import { repeatWhen } from "rxjs/operators";
const RECONNECTION_DELAY = 2000;
export const MesosStreamType = Symbol("MesosStreamType");
export default stream({ type: "SUBSCRIBE" }, "/mesos/api/v1?subscribe").pipe(
repeatWhen(() => timer(RECONNECTION_DELAY))
);
开发者ID:dcos,项目名称:dcos-ui,代码行数:11,代码来源:MesosStream.ts
注:本文中的rxjs/operators.repeatWhen函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论