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


TypeScript operators.toArray函數代碼示例

本文整理匯總了TypeScript中rxjs/operators.toArray函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript toArray函數的具體用法?TypeScript toArray怎麽用?TypeScript toArray使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了toArray函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it('should reset stubs used by .select', () => {
    const instance = TestBed.createComponent(TestComponent).debugElement
      .componentInstance;

    const stub1 = MockNgRedux.getSelectorStub('baz');
    stub1.next(1);
    stub1.next(2);
    stub1.complete();

    instance.baz$
      .pipe(toArray())
      .subscribe((values: number[]) => expect(values).toEqual([1, 2]));

    MockNgRedux.reset();

    // Reset should result in a new stub getting created.
    const stub2 = MockNgRedux.getSelectorStub('baz');
    expect(stub1 === stub2).toBe(false);

    stub2.next(3);
    stub2.complete();

    instance.obs$
      .pipe(toArray())
      .subscribe((values: number[]) => expect(values).toEqual([3]));
  });
開發者ID:GopinathKaliappan,項目名稱:store,代碼行數:26,代碼來源:ng-redux.mock.spec.ts

示例2: it

  it('emits 0 initially, the right count when sources emit their own count, and ends with zero', async () => {
    const { httpService, http } = setup();

    const countA$ = new Rx.Subject<number>();
    const countB$ = new Rx.Subject<number>();
    const countC$ = new Rx.Subject<number>();
    const promise = http
      .getLoadingCount$()
      .pipe(toArray())
      .toPromise();

    http.addLoadingCount(countA$);
    http.addLoadingCount(countB$);
    http.addLoadingCount(countC$);

    countA$.next(100);
    countB$.next(10);
    countC$.next(1);
    countA$.complete();
    countB$.next(20);
    countC$.complete();
    countB$.next(0);

    httpService.stop();
    expect(await promise).toMatchSnapshot();
  });
開發者ID:elastic,項目名稱:kibana,代碼行數:26,代碼來源:http_service.test.ts

示例3: test

test('observe latest', t => {
  const service = new MqttService(t.context.mqtt);
  const obs = service.observeLatest('/test1/hallo1', '/test/+').pipe(
    take(2),
    Ha4usOperators.pickEach('ts'),
    toArray()
  );
  obs.subscribe((msgs: any[]) => {
    t.deepEqual(msgs, [[1, 2], [1, 3]]);
  });

  t.context.mqtt.publish('test1/hallo1', '{"val":"helloworld","ts":1}', {
    retain: false,
    qos: 0,
  });

  t.context.mqtt.publish('test/hallo2', '{"val":"helloworld","ts":2}', {
    retain: false,
    qos: 0,
  });
  t.context.mqtt.publish('test/hallo3', '{"val":"helloworld","ts":3}', {
    retain: false,
    qos: 0,
  });
});
開發者ID:ha4us,項目名稱:ha4us.old,代碼行數:25,代碼來源:mqtt.service.spec.ts

示例4: test

 test("returns an Observable with an initial state of idle", done => {
   const action$ = ActionsObservable.of({
     type: actionsModule.LAUNCH_KERNEL_SUCCESSFUL,
     payload: {
       kernel: {
         channels: of({
           header: { msg_type: "status" },
           content: { execution_state: "idle" }
         }) as Subject<any>,
         cwd: "/home/tester",
         type: "websocket"
       },
       kernelRef: "fakeKernelRef",
       contentRef: "fakeContentRef",
       selectNextKernel: false
     }
   });
   const obs = watchExecutionStateEpic(action$);
   obs.pipe(toArray()).subscribe(
     // Every action that goes through should get stuck on an array
     actions => {
       const types = actions.map(({ type }) => type);
       expect(types).toEqual([actionsModule.SET_EXECUTION_STATE]);
     },
     err => done.fail(err), // It should not error in the stream
     () => done()
   );
 });
開發者ID:kelleyblackmore,項目名稱:nteract,代碼行數:28,代碼來源:kernel-lifecycle.spec.ts

示例5: test

 test("Informs about disconnected kernels, allows reconnection", async () => {
   const state$ = {
     value: {
       core: stateModule.makeStateRecord({
         kernelRef: "fake",
         entities: stateModule.makeEntitiesRecord({
           contents: stateModule.makeContentsRecord({
             byRef: Immutable.Map({
               fakeContent: stateModule.makeNotebookContentRecord()
             })
           }),
           kernels: stateModule.makeKernelsRecord({
             byRef: Immutable.Map({
               fake: stateModule.makeRemoteKernelRecord({
                 channels: null,
                 status: "not connected"
               })
             })
           })
         })
       }),
       app: {
         notificationSystem: { addNotification: jest.fn() }
       }
     }
   };
   const action$ = ActionsObservable.of(
     actions.executeCell({ id: "first", contentRef: "fakeContentRef" })
   );
   const responses = await executeCellEpic(action$, state$)
     .pipe(toArray())
     .toPromise();
   expect(responses).toEqual([]);
 });
開發者ID:nteract,項目名稱:nteract,代碼行數:34,代碼來源:execute.spec.ts

示例6: it

 it("extracts all execution counts from a session", () => {
   return of(
     status("starting"),
     status("idle"),
     status("busy"),
     executeInput({
       code: "display('woo')\ndisplay('hoo')",
       execution_count: 0
     }),
     displayData({ data: { "text/plain": "woo" } }),
     displayData({ data: { "text/plain": "hoo" } }),
     executeInput({
       code: "",
       execution_count: 1
     }),
     status("idle")
   )
     .pipe(
       executionCounts(),
       toArray()
     )
     .toPromise()
     .then(arr => {
       expect(arr).toEqual([0, 1]);
     });
 });
開發者ID:kelleyblackmore,項目名稱:nteract,代碼行數:26,代碼來源:messaging-spec.ts

示例7: test

  test("handles multiple socket routing underneath", () => {
    const shellSocket = new EventEmitter();
    const iopubSocket = new EventEmitter();
    const sockets = ({
      shell: shellSocket,
      iopub: iopubSocket
    } as any) as Sockets;

    const channels = createMainChannelFromSockets(sockets);

    const p = channels
      .pipe(
        take(2),
        toArray()
      )
      .toPromise();

    shellSocket.emit("message", { yolo: false });
    iopubSocket.emit("message", { yolo: true });

    return p.then((modifiedMessages: any) => {
      expect(modifiedMessages).toEqual([
        { channel: "shell", yolo: false },
        { channel: "iopub", yolo: true }
      ]);
    });
  });
開發者ID:kelleyblackmore,項目名稱:nteract,代碼行數:27,代碼來源:index_spec.ts


注:本文中的rxjs/operators.toArray函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。