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


TypeScript operators.takeLast函數代碼示例

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


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

示例1: observableDefer

  return observableDefer(() => {
    log.debug("Init: Trying to call endOfStream");
    if (mediaSource.readyState !== "open") {
      log.debug("Init: MediaSource not open, cancel endOfStream");
      return observableOf(null);
    }

    const { sourceBuffers } = mediaSource;
    const updatingSourceBuffers = getUpdatingSourceBuffers(sourceBuffers);

    if (!updatingSourceBuffers.length) {
      log.info("Init: Triggering end of stream");
      mediaSource.endOfStream();
      return observableOf(null);
    }

    log.debug("Init: Waiting SourceBuffers to be updated before calling endOfStream.");
    const updatedSourceBuffers$ = updatingSourceBuffers
      .map((sourceBuffer) => onUpdate$(sourceBuffer).pipe(take(1)));

    return observableRace(
      observableMerge(...updatedSourceBuffers$).pipe(takeLast(1)),
      onRemoveSourceBuffers$(sourceBuffers).pipe(take(1))
    ).pipe(mergeMap(() => {
      return triggerEndOfStream(mediaSource);
    }));
  });
開發者ID:canalplus,項目名稱:rx-player,代碼行數:27,代碼來源:end_of_stream.ts

示例2: it

  it('should take one value from an observable with many values', () => {
    const e1 = hot('--a--^--b----c---d--|   ');
    const e1subs =      '^              !   ';
    const expected =    '---------------(d|)';

    expectObservable(e1.pipe(takeLast(1))).toBe(expected);
    expectSubscriptions(e1.subscriptions).toBe(e1subs);
  });
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:8,代碼來源:takeLast-spec.ts

示例3: it

 it('completes when service is stopped', async () => {
   const last$ = start
     .getNavLinks$()
     .pipe(takeLast(1))
     .toPromise();
   service.stop();
   await expect(last$).resolves.toBeInstanceOf(Array);
 });
開發者ID:elastic,項目名稱:kibana,代碼行數:8,代碼來源:nav_links_service.test.ts


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