当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript operators.concatMapTo函数代码示例

本文整理汇总了TypeScript中rxjs/operators.concatMapTo函数的典型用法代码示例。如果您正苦于以下问题:TypeScript concatMapTo函数的具体用法?TypeScript concatMapTo怎么用?TypeScript concatMapTo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了concatMapTo函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

  it('should support the deprecated resultSelector', () => {
    const results: Array<number[]> = [];

    of(1, 2, 3).pipe(
      concatMapTo(
        of(4, 5, 6),
        (a, b, i, ii) => [a, b, i, ii]
      )
    )
    .subscribe({
      next (value) {
        results.push(value);
      },
      error(err) {
        throw err;
      },
      complete() {
        expect(results).to.deep.equal([
          [1, 4, 0, 0],
          [1, 5, 0, 1],
          [1, 6, 0, 2],
          [2, 4, 1, 0],
          [2, 5, 1, 1],
          [2, 6, 1, 2],
          [3, 4, 2, 0],
          [3, 5, 2, 1],
          [3, 6, 2, 2],
        ]);
      }
    });
  });
开发者ID:MykhailoIskiv,项目名称:rxjs,代码行数:31,代码来源:concatMapTo-spec.ts

示例2: concatMapTo2

  concatMapTo2() {
    // emit value every 2 seconds
    const interval$ = interval(2000);
    // emit value every second for 5 seconds
    const source = interval(1000).pipe(take(5));
    /*
      ***Be Careful***: In situations like this where the source emits at a faster pace
      than the inner observable completes, memory issues can arise.
      (interval emits every 1 second, basicTimer completes every 5)
    */
    //  basicTimer will complete after 5 seconds, emitting 0,1,2,3,4
    const example = interval$.pipe(
      concatMapTo(
        source,
        (firstInterval, secondInterval) => `${firstInterval} ${secondInterval}`
      )
    );
    /*
      output: 0 0
              0 1
              0 2
              0 3
              0 4
              1 0
              1 1
              continued...

    */
    const subscribe = example.subscribe(val => console.log(val));
  }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:30,代码来源:transforming.service.ts

示例3: concatMapTo1

 concatMapTo1() {
   // emit value every 2 seconds
   const sampleInterval = interval(500).pipe(take(5));
   const fakeRequest = of('Network request complete').pipe(delay(3000));
   // wait for first to complete before next is subscribed
   const example = sampleInterval.pipe(concatMapTo(fakeRequest));
   // result
   // output: Network request complete...3s...Network request complete'
   const subscribe = example.subscribe(val => console.log(val));
 }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:10,代码来源:transforming.service.ts

示例4: hot

  ('should map-and-flatten each item to an Observable', () => {
    const e1 =    hot('--1-----3--5-------|');
    const e1subs =    '^                  !';
    const e2 =   cold('x-x-x|              ', {x: 10});
    const expected =  '--x-x-x-x-x-xx-x-x-|';
    const values = {x: 10};

    const result = e1.pipe(concatMapTo(e2));

    expectObservable(result).toBe(expected, values);
    expectSubscriptions(e1.subscriptions).toBe(e1subs);
  });
开发者ID:MykhailoIskiv,项目名称:rxjs,代码行数:12,代码来源:concatMapTo-spec.ts


注:本文中的rxjs/operators.concatMapTo函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。