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