當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript operators.bufferToggle函數代碼示例

本文整理匯總了TypeScript中rxjs/operators.bufferToggle函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript bufferToggle函數的具體用法?TypeScript bufferToggle怎麽用?TypeScript bufferToggle使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了bufferToggle函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it('should emit buffers using constying cold closings', () => {
    const e1 = hot('--a--^---b---c---d---e---f---g---h------|      ');
    const e2 =     cold('--x-----------y--------z---|              ');
    const subs =        '^                                  !      ';
    const closings = [
      cold(             '---------------s--|                     '),
      cold(                         '----(s|)                    '),
      cold(                                  '---------------(s|)')];
    const closeSubs =  ['  ^              !                        ',
                      '              ^   !                       ',
                      '                       ^           !      '];
    const expected =    '-----------------ij----------------(k|)   ';
    const values = {
      i: ['b', 'c', 'd', 'e'],
      j: ['e'],
      k: ['g', 'h']
    };

    let i = 0;
    const result = e1.pipe(bufferToggle(e2, () => closings[i++]));

    expectObservable(result).toBe(expected, values);
    expectSubscriptions(e1.subscriptions).toBe(subs);
    expectSubscriptions(closings[0].subscriptions).toBe(closeSubs[0]);
    expectSubscriptions(closings[1].subscriptions).toBe(closeSubs[1]);
    expectSubscriptions(closings[2].subscriptions).toBe(closeSubs[2]);
  });
開發者ID:tomastrajan,項目名稱:rxjs,代碼行數:27,代碼來源:bufferToggle-spec.ts

示例2: interval

 observable1 = constructorZone1.run(() => {
   const source = interval(10);
   const opening = interval(25);
   const closingSelector = (v: any) => {
     expect(Zone.current.name).toEqual(constructorZone1.name);
     return v % 2 === 0 ? of(v) : empty();
   };
   return source.pipe(bufferToggle(opening, closingSelector));
 });
開發者ID:angular,項目名稱:zone.js,代碼行數:9,代碼來源:rxjs.Observable.buffer.spec.ts

示例3: it

  it('should handle empty source', () => {
    const e1 =  cold('|');
    const e2 =  cold('--o-----|');
    const e3 =  cold(  '-----c--|');
    const expected = '|';
    const values = { x: [] as string[] };

    const result = e1.pipe(bufferToggle(e2, () => e3));

    expectObservable(result).toBe(expected, values);
  });
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:11,代碼來源:bufferToggle-spec.ts


注:本文中的rxjs/operators.bufferToggle函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。