當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。