• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript operators.toArray函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript operators.window函数代码示例发布时间:2022-05-25
下一篇:
TypeScript operators.timestamp函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap