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


TypeScript operators.exhaustMap函数代码示例

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


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

示例1: map

> => (action$, state$, { selectLogFilterQueryAsJson, selectVisibleLogSummary }) => {
  const filterQuery$ = state$.pipe(map(selectLogFilterQueryAsJson));
  const summaryInterval$ = state$.pipe(
    map(selectVisibleLogSummary),
    map(({ start, end }) => (start && end ? getLoadParameters(start, end) : null)),
    filter(isNotNull)
  );

  const shouldLoadBetweenNewInterval$ = action$.pipe(
    filter(logPositionActions.reportVisibleSummary.match),
    filter(
      ({ payload: { bucketsOnPage, pagesBeforeStart, pagesAfterEnd } }) =>
        bucketsOnPage < MINIMUM_BUCKETS_PER_PAGE ||
        pagesBeforeStart < MINIMUM_BUFFER_PAGES ||
        pagesAfterEnd < MINIMUM_BUFFER_PAGES
    ),
    map(({ payload: { start, end } }) => getLoadParameters(start, end))
  );

  const shouldLoadWithNewFilter$ = action$.pipe(
    filter(logFilterActions.applyLogFilterQuery.match),
    withLatestFrom(filterQuery$, (filterQuery, filterQueryString) => filterQueryString)
  );

  return merge(
    shouldLoadBetweenNewInterval$.pipe(
      withLatestFrom(filterQuery$),
      exhaustMap(([{ start, end, bucketSize }, filterQuery]) => [
        loadSummary({
          start,
          end,
          sourceId: 'default',
          bucketSize,
          filterQuery,
        }),
      ])
    ),
    shouldLoadWithNewFilter$.pipe(
      withLatestFrom(summaryInterval$),
      exhaustMap(([filterQuery, { start, end, bucketSize }]) => [
        loadSummary({
          start,
          end,
          sourceId: 'default',
          bucketSize: (end - start) / LOAD_BUCKETS_PER_PAGE,
          filterQuery,
        }),
      ])
    )
  );
};
开发者ID:gingerwizard,项目名称:kibana,代码行数:51,代码来源:epic.ts

示例2: exhaustMap2

  exhaustMap2() {
    const firstInterval = interval(1000).pipe(take(10));
    const secondInterval = interval(1000).pipe(take(2));

    const exhaustSub = firstInterval
      .pipe(
        exhaustMap(f => {
          console.log(`Emission Corrected of first interval: ${f}`);
          return secondInterval;
        })
      )
      /*
        When we subscribed to the first interval, it starts to emit a values (starting 0).
        This value is mapped to the second interval which then begins to emit (starting 0).
        While the second interval is active, values from the first interval are ignored.
        We can see this when firstInterval emits number 3,6, and so on...

          Output:
          Emission of first interval: 0
          0
          1
          Emission of first interval: 3
          0
          1
          Emission of first interval: 6
          0
          1
          Emission of first interval: 9
          0
          1
      */
      .subscribe(s => console.log(s));
  }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:33,代码来源:transforming.service.ts

示例3: map

> => (
  action$,
  state$,
  { selectMetricTimeUpdatePolicyInterval, selectMetricRangeFromTimeRange }
) => {
  const updateInterval$ = state$.pipe(
    map(selectMetricTimeUpdatePolicyInterval),
    filter(isNotNull)
  );

  const range$ = state$.pipe(
    map(selectMetricRangeFromTimeRange),
    filter(isNotNull)
  );

  return action$.pipe(
    filter(startMetricsAutoReload.match),
    withLatestFrom(updateInterval$, range$),
    exhaustMap(([action, updateInterval, range]) =>
      timer(0, updateInterval).pipe(
        map(() =>
          setRangeTime({
            from: moment()
              .subtract(range, 'ms')
              .valueOf(),
            to: moment().valueOf(),
            interval: '1m',
          })
        ),
        takeUntil(action$.pipe(filter(stopMetricsAutoReload.match)))
      )
    )
  );
};
开发者ID:gingerwizard,项目名称:kibana,代码行数:34,代码来源:epic.ts

示例4: it

  it('should not break unsubscription chains when result is unsubscribed explicitly', () => {
    const x = cold(     '--a--b--c--|                               ');
    const xsubs =    '   ^          !                               ';
    const y = cold(               '--d--e--f--|                     ');
    const ysubs: string[] = [];
    const z = cold(                                 '--g--h--i--|   ');
    const zsubs =    '                               ^  !           ';
    const e1 =   hot('---x---------y-----------------z-------------|');
    const e1subs =   '^                                 !           ';
    const expected = '-----a--b--c---------------------g-           ';
    const unsub =    '                                  !           ';

    const observableLookup = { x: x, y: y, z: z };

    const result = e1.pipe(
      mergeMap(x => of(x)),
      exhaustMap(value => observableLookup[value]),
      mergeMap(x => of(x))
    );

    expectObservable(result, unsub).toBe(expected);
    expectSubscriptions(x.subscriptions).toBe(xsubs);
    expectSubscriptions(y.subscriptions).toBe(ysubs);
    expectSubscriptions(z.subscriptions).toBe(zsubs);
    expectSubscriptions(e1.subscriptions).toBe(e1subs);
  });
开发者ID:jaychsu,项目名称:RxJS,代码行数:26,代码来源:exhaustMap-spec.ts

示例5: exhaustMap1

  exhaustMap1() {
    const sourceInterval = interval(1000);
    const delayedInterval = sourceInterval.pipe(delay(10), take(4));

    const exhaustSub = merge(
      //  delay 10ms, then start interval emitting 4 values
      delayedInterval,
      //  emit immediately
      of(true)
    )
      .pipe(exhaustMap(_ => sourceInterval.pipe(take(5))))
      /*
       *  The first emitted value (of(true)) will be mapped
       *  to an interval observable emitting 1 value every
       *  second, completing after 5.
       *  Because the emissions from the delayed interval
       *  fall while this observable is still active they will be ignored.
       *
       *  Contrast this with concatMap which would queue,
       *  switchMap which would switch to a new inner observable each emission,
       *  and mergeMap which would maintain a new subscription for each emitted value.
       */
      //  output: 0, 1, 2, 3, 4
      .subscribe(val => console.log(val));
  }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:25,代码来源:transforming.service.ts

示例6: filter

export const createLogPositionEpic = <State>(): Epic<Action, Action, State, {}> => action$ =>
  action$.pipe(
    filter(startAutoReload.match),
    exhaustMap(({ payload }) =>
      timer(0, payload).pipe(
        map(() => jumpToTargetPositionTime(Date.now())),
        takeUntil(action$.pipe(filter(stopAutoReload.match)))
      )
    )
  );
开发者ID:elastic,项目名称:kibana,代码行数:10,代码来源:epic.ts

示例7: 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-y-y-y------|';
    const values = {x: 10, y: 30, z: 50};

    const result = e1.pipe(exhaustMap(x => e2.map(i => i * +x)));

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


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