• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript rxjs.defer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: it

  it('should render the error message if the poll response`s job status is "failed"', fakeAsync(() => {
    const searchResponse = new PcapStatusResponse();
    searchResponse.jobId = '42';

    pcapService.submitRequest = jasmine.createSpy('submitRequest').and.returnValue(
      defer(() => Promise.resolve(searchResponse))
    );

    const pollResponse = new PcapStatusResponse();
    pollResponse.jobStatus = 'FAILED';
    pcapService.pollStatus = jasmine.createSpy('pollStatus').and.returnValue(
      defer(() => Promise.resolve(pollResponse))
    );

    component.onSearch(new PcapRequest());

    tick();
    fixture.detectChanges();

    expect(
      fixture.debugElement.query(By.css('[data-qe-id="error"]'))
      .nativeElement
      .textContent.trim()
    ).toBe(`Query status: ${pollResponse.jobStatus}. Check your filter criteria and try again!`);
  }));
开发者ID:merrimanr,项目名称:incubator-metron,代码行数:25,代码来源:pcap-panel.component.spec.ts


示例2: intercept

 public async intercept(
   interceptors: NestInterceptor[],
   args: any[],
   instance: Controller,
   callback: (...args) => any,
   next: () => Promise<any>,
 ): Promise<any> {
   if (!interceptors || isEmpty(interceptors)) {
     return await await next();
   }
   const context = this.createContext(args, instance, callback);
   const start$ = defer(() => this.transformDeffered(next));
   /***
     const nextFn =  (i: number) => async () => {
     if (i <= interceptors.length) {
       return start$;
     }
     return await interceptors[i].intercept(context, nextFn(i + 1) as any);
   };
   */
   const result$ = await interceptors.reduce(
     async (stream$, interceptor) =>
       await interceptor.intercept(context, await stream$),
     Promise.resolve(start$),
   );
   return await result$.toPromise();
 }
开发者ID:timokae,项目名称:nest,代码行数:27,代码来源:interceptors-consumer.ts


示例3: mergeMap

 mergeMap(() => defer(() =>
   of(2, asapScheduler)
 ).pipe(
   mergeMap(() => defer(() =>
     of(3, asapScheduler)
   ))
 ))
开发者ID:jaychsu,项目名称:RxJS,代码行数:7,代码来源:mergeMap-spec.ts


示例4: Actions

    useFactory: (): Observable<any> => {
      if (typeof factoryOrSource === 'function') {
        return new Actions(defer(factoryOrSource));
      }

      return new Actions(factoryOrSource);
    },
开发者ID:AlexChar,项目名称:platform,代码行数:7,代码来源:testing.ts


示例5: observableDefer

/**
 * Set the MediaKeys object on the HTMLMediaElement if it is not already on the
 * element.
 * If a MediaKeys was already set on it, dispose of it before setting the new
 * one.
 *
 * /!\ Mutates heavily currentMediaKeysInfos
 * @param {Object} mediaKeysInfos
 * @param {HTMLMediaElement} mediaElement
 * @param {Object} currentMediaKeysInfos
 * @returns {Observable}
 */
export default function attachMediaKeys(
  mediaKeysInfos: IMediaKeysInfos,
  mediaElement : HTMLMediaElement,
  currentMediaKeysInfos: MediaKeysInfosStore
) : Observable<unknown> {
  return observableDefer(() => {
    const previousState = currentMediaKeysInfos.getState(mediaElement);
    const {
      keySystemOptions,
      mediaKeySystemAccess,
      mediaKeys,
      sessionsStore,
    } = mediaKeysInfos;

    currentMediaKeysInfos.setState(mediaElement, {
      keySystemOptions,
      mediaKeySystemAccess,
      mediaKeys,
      sessionsStore,
    });

    return (
      previousState && previousState.sessionsStore !== sessionsStore ?
        previousState.sessionsStore.closeAllSessions() :
        observableOf(null)
    ).pipe(mergeMap(() => {
      if (mediaElement.mediaKeys === mediaKeys) {
        return observableOf(null);
      }

      log.debug("EME: Setting MediaKeys");
      return setMediaKeys(mediaElement, mediaKeys);
    }));
  });
}
开发者ID:canalplus,项目名称:rx-player,代码行数:47,代码来源:attach_media_keys.ts


示例6: observableDefer

/**
 * Trigger the `endOfStream` method of a MediaSource.
 *
 * If the MediaSource is ended/closed, do not call this method.
 * If SourceBuffers are updating, wait for them to be updated before closing
 * it.
 * @param {MediaSource} mediaSource
 * @returns {Observable}
 */
export default function triggerEndOfStream(
  mediaSource : MediaSource
) : Observable<null> {
  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,代码行数:40,代码来源:end_of_stream.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript rxjs.empty函数代码示例发布时间:2022-05-25
下一篇:
TypeScript rxjs.concat函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap