本文整理汇总了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);
});
示例2: higherOrder
export function repeatWhen<T>(this: Observable<T>, notifier: (notifications: Observable<any>) => Observable<any>): Observable<T> {
return higherOrder(notifier)(this) as Observable<T>;
}
示例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))
);