當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript operators.repeatWhen函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。