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


TypeScript operators.buffer函数代码示例

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


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

示例1: asDiagram

 asDiagram('buffer')('should emit buffers that close and reopen', () => {
   const a =    hot('-a-b-c-d-e-f-g-h-i-|');
   const b =    hot('-----B-----B-----B-|');
   const expected = '-----x-----y-----z-|';
   const expectedValues = {
     x: ['a', 'b', 'c'],
     y: ['d', 'e', 'f'],
     z: ['g', 'h', 'i']
   };
   expectObservable(a.pipe(buffer(b))).toBe(expected, expectedValues);
 });
开发者ID:DallanQ,项目名称:rxjs,代码行数:11,代码来源:buffer-spec.ts

示例2: it

  it('should unsubscribe notifier when source unsubscribed', () => {
    const a =    hot('-a-b-c-d-e-f-g-h-i-|');
    const b =    hot('-----1-----2-----3-|');
    const bsubs =    '^    !';
    const expected = '-----(x|)';
    const expectedValues = {
      x: ['a', 'b', 'c'],
    };

    expectObservable(a.pipe(buffer(b), take(1))).toBe(expected, expectedValues);
    expectSubscriptions(b.subscriptions).toBe(bsubs);
  });
开发者ID:DallanQ,项目名称:rxjs,代码行数:12,代码来源:buffer-spec.ts

示例3: buffer1

 buffer1() {
   // Create an observable that emits a value every second
   const myInterval = interval(1000);
   // Create an observable that emits every time document is clicked
   const bufferBy = fromEvent(document, 'click');
   /*
     Collect all values emitted by our interval observable until we click document.
     This will cause the bufferBy Observable to emit a value, satisfying the buffer.
     Pass us all collected values since last buffer as an array.
   */
   const myBufferedInterval = myInterval.pipe(buffer(bufferBy));
   // Print values to console
   // ex. output: [1,2,3] ... [4,5,6,7,8]
   const subscribe = myBufferedInterval.subscribe(val =>
     console.log(' Buffered Values:', val)
   );
 }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:17,代码来源:transforming.service.ts


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