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