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


TypeScript rxjs.range函數代碼示例

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


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

示例1: range

 observable1 = constructorZone1.run(() => {
   return range(0, 3).pipe(
       map(function(x: any) {
         return range(x, 3);
       }),
       switchAll());
 });
開發者ID:angular,項目名稱:zone.js,代碼行數:7,代碼來源:rxjs.Observable.merge.spec.ts

示例2: range

export const createEcho = (): Echo => {
  const echoEffect = range(1, 5)
    .pipe(
      mergeMap(i => of(i).pipe(delay(500 * i))),
      repeat(),
    )

  const { eventStream: mouseoutStream, next: mouseout } = ngEventHandler<void>()
  const { eventStream: mouseoverStream, next: mouseover } = ngEventHandler<void>()

  const def = of(0)

  const effect = merge(
      of(def),
      mouseoverStream.pipe(
        map(() => echoEffect.pipe(takeUntil(mouseoutStream)))),
      mouseoutStream.pipe(map(() => def))
    )
    .pipe(mergeAll())

  return {
    mouseout,
    mouseover,
    effect$: effect,
  }
}
開發者ID:jamesbs,項目名稱:flashcards,代碼行數:26,代碼來源:echo.ts

示例3: Promise

      await new Promise(resolve => {
        range(0, trackDatas.length)
          .pipe(
            concatMap(index => {
              return from(
                new Promise(resolve2 => {
                  createTrack({
                    name: trackDatas[index].name,
                    desc: '',
                    creatorId: taskBoard.get('ownerId'),
                    boardId: taskBoardDomain.id
                  }).then(trackData => {
                    TaskCardModel
                      .where({
                        taskTrackId: trackDatas[index].id
                      })
                      .fetchAll().then(cards => {
                        const cardDatas = cards.map(c => {
                          return {
                            id: c.id,
                            title: c.get('title'),
                            type: c.get('type')
                          };
                        });

                        range(0, cardDatas.length)
                          .pipe(
                            concatMap(index2 => {
                              return from(
                                new Promise(resolve3 => {
                                  createTaskCard({
                                    title: cardDatas[index2].title,
                                    boardId: taskBoard.id,
                                    trackId: trackData.id,
                                    type: cardDatas[index2].type || TaskCardType.NORMAL,
                                    creatorId: taskBoard.get('ownerId')
                                  }).then(() => {
                                    resolve3();
                                  });
                                })
                              );
                            })
                          )
                          .subscribe({
                            complete: () => {
                              resolve2();
                            }
                          });
                      });
                  });
                })
              );
            })
          )
          .subscribe({
            complete: () => {
              resolve();
            }
          });
      });
開發者ID:A-Horse,項目名稱:bblist-backend,代碼行數:60,代碼來源:migrations.ts

示例4: range

                      .fetchAll().then(cards => {
                        const cardDatas = cards.map(c => {
                          return {
                            id: c.id,
                            title: c.get('title'),
                            type: c.get('type')
                          };
                        });

                        range(0, cardDatas.length)
                          .pipe(
                            concatMap(index2 => {
                              return from(
                                new Promise(resolve3 => {
                                  createTaskCard({
                                    title: cardDatas[index2].title,
                                    boardId: taskBoard.id,
                                    trackId: trackData.id,
                                    type: cardDatas[index2].type || TaskCardType.NORMAL,
                                    creatorId: taskBoard.get('ownerId')
                                  }).then(() => {
                                    resolve3();
                                  });
                                })
                              );
                            })
                          )
                          .subscribe({
                            complete: () => {
                              resolve2();
                            }
                          });
                      });
開發者ID:A-Horse,項目名稱:bblist-backend,代碼行數:33,代碼來源:migrations.ts

示例5: it

 it('should count a range() source observable', (done: MochaDone) => {
   range(1, 10).pipe(count()).subscribe(
     (value: number) => {
       expect(value).to.equal(10);
     }, (x) => {
       done(new Error('should not be called'));
     }, () => {
       done();
     });
 });
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:10,代碼來源:count-spec.ts

示例6: range

    return errors => range(1, 10).pipe(
        zip(errors, (i, err) => {
            if (i == 10) {
                throw err;
            }

            return i;
        }),
        flatMap(i => timer(i * 1000)),
    )
開發者ID:urandom,項目名稱:readeef,代碼行數:10,代碼來源:api.ts

示例7: it

  it('should reduce with index with seed', (done: MochaDone) => {
    const idx = [0, 1, 2, 3, 4, 5];

    range(0, 6).pipe(reduce((acc, value, index) => {
      expect(idx.shift()).to.equal(index);
      return value;
    }, -1)).subscribe(null, null, () => {
      expect(idx).to.be.empty;
      done();
    });
  });
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:11,代碼來源:reduce-spec.ts

示例8: it

  it('should not work after has been disposed', function(done) {
    const number$ = range(1, 3).pipe(concatMap(x => of(x).pipe(delay(150))));

    function app(_sources: any): any {
      return {other: number$};
    }

    const {sources, run: _run} = setup(app, {
      other: (num$: any) => from(num$).pipe(map((num: any) => 'x' + num)),
    });

    let dispose: any;
    sources.other.subscribe(function(x: any) {
      assert.notStrictEqual(x, 'x3');
      if (x === 'x2') {
        dispose();
        setTimeout(() => {
          done();
        }, 100);
      }
    });
    dispose = _run();
  });
開發者ID:ntilwalli,項目名稱:cyclejs,代碼行數:23,代碼來源:index.ts

示例9: map

 map(function(x: any) {
   return range(x, 3);
 }),
開發者ID:angular,項目名稱:zone.js,代碼行數:3,代碼來源:rxjs.Observable.merge.spec.ts

示例10: range

import { range } from 'rxjs';
import { filter, map, reduce, tap } from 'rxjs/operators';

// observable
const range$ = range(1, 10);

// subscription
range$
  .pipe(
    map(item => item * 10),
    filter(item => item % 20 === 0),
    reduce((accumulator, item) => accumulator + item),
    tap(sum => console.log(sum))
  )
  .subscribe();
開發者ID:jesuscc1993,項目名稱:demos,代碼行數:15,代碼來源:operators.ts


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