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


TypeScript operators.bufferTime函数代码示例

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


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

示例1: get

 public get(
   query: Ha4usObjectQuery,
   aTimeout: number = 500
 ): Promise<IStatefulObject[]> {
   return this.$objects
     .observe(query)
     .pipe(
       mergeMap((aObject: Ha4usObject) => {
         return this.$states.observe(aObject.topic).pipe(
           timeoutWith(100, of({})),
           take(1),
           map((state: Ha4usMessage) => {
             delete state.topic
             delete state.match
             return {
               object: aObject,
               state: state,
             }
           })
         )
       }),
       bufferTime(aTimeout),
       timeout(aTimeout * 2)
     )
     .toPromise()
 }
开发者ID:ha4us,项目名称:ha4us.old,代码行数:26,代码来源:stateful-objects.service.ts

示例2: it

  it('should emit buffers with timeSpan 100 and creationInterval 70', () => {
    const e1 = hot('--1--^2--3---4---5--6--7---8----9------------|');
                    // -------*------*------*------*------*----- creation interval
                    // ----------|                               timespans
                    //        ----------|
                    //               ----------|
                    //                      ----------|
                    //                             ----------|
                    //                                    ----------|
    const e1subs =      '^                                       !';
    const t = time(     '----------|');
    const interval = time(        '-------|');
    const expected =    '----------a------b------c------d------e-(f|)';
    const values = {
      a: ['2', '3', '4'],
      b: ['4', '5', '6'],
      c: ['6', '7', '8'],
      d: ['8', '9'],
      e: [] as string[],
      f: [] as string[]
    };

    const result = e1.pipe(bufferTime(t, interval, Number.POSITIVE_INFINITY, rxTestScheduler));

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

示例3: bufferTime1

 bufferTime1() {
   // Create an observable that emits a value every 500ms
   const source = interval(500);
   // After 2 seconds have passed, emit buffered values as an array
   const example = source.pipe(bufferTime(2000));
   // Print values to console
   // ex. output [0,1,2]...[3,4,5,6]
   const subscribe = example.subscribe(val =>
     console.log('Buffered with Time:', val)
   );
 }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:11,代码来源:transforming.service.ts

示例4: bufferTime2

 bufferTime2() {
   // Create an observable that emits a value every 500ms
   const source = interval(500);
   /*
     bufferTime also takes second argument, when to start the next buffer (time in ms)
     for instance, if we have a bufferTime of 2 seconds but second argument (bufferCreationInterval) of 1 second:
     ex. output: [0,1,2]...[1,2,3,4,5]...[3,4,5,6,7]
   */
   const example = source.pipe(bufferTime(2000, 1000));
   // Print values to console
   const subscribe = example.subscribe(val =>
     console.log('Start Buffer Every 1s:', val)
   );
 }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:14,代码来源:transforming.service.ts

示例5: values

 return (actor$: Observable<Actor>) => {
   return actor$.pipe(
     rxFilter((actor) => RequestActor.isPreRequestActor(actor)),
     rxObserveOn(asyncScheduler),
     rxBufferTime(100),
     rxFilter((actors) => actors.length > 0),
     rxMergeMap((actors) => {
       const nextActors = {} as Dictionary<Actor>;
       actors.forEach((actor) => {
         nextActors[actor.type + JSON.stringify(actor.arg)] = actor;
       });
       return values(nextActors);
     }),
   );
 };
开发者ID:querycap,项目名称:reactorx,代码行数:15,代码来源:createCombineDuplicatedRequestEpic.ts


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