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


TypeScript Observable.first方法代碼示例

本文整理匯總了TypeScript中rxjs.Observable.first方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Observable.first方法的具體用法?TypeScript Observable.first怎麽用?TypeScript Observable.first使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rxjs.Observable的用法示例。


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

示例1: getWatchHandlers

function getWatchHandlers(
  buildOutput$: Observable<string>,
  {
    handlerDelay = defaultHandlerDelay,
    handlerReadinessTimeout = defaultHandlerReadinessTimeout,
  }: IWatchOptions
) {
  const typescriptHandler = buildOutput$
    .first(data => data.includes('$ tsc'))
    .map(() =>
      buildOutput$
        .first(data => data.includes('Compilation complete.'))
        .mapTo('tsc')
    );

  const webpackHandler = buildOutput$
    .first(data => data.includes('$ webpack'))
    .map(() =>
      buildOutput$.first(data => data.includes('Chunk Names')).mapTo('webpack')
    );

  const defaultHandler = Observable.of(undefined)
    .delay(handlerReadinessTimeout)
    .map(() =>
      buildOutput$.timeout(handlerDelay).catch(() => Observable.of('timeout'))
    );

  return [typescriptHandler, webpackHandler, defaultHandler];
}
開發者ID:JinlongHe,項目名稱:kibana,代碼行數:29,代碼來源:watch.ts

示例2: return

	    return (control: FormControl) => {
				return names$.first()
					.map(res => R.map((n: string) => (n) ? n.toLowerCase() : n)(res))
					.map(res => R.contains(control.value.toLowerCase())(res))
					.map(res => (res) ? ({ 'duplicated': true }) : null)
					.toPromise();
			}
開發者ID:simbiosis-group,項目名稱:ion2-claim,代碼行數:7,代碼來源:extra-validators.ts

示例3: constructor

  constructor(
    public platform: Platform,
    private _config: Config,
    private _translateService: TranslateService,
    private _splashScreen: SplashScreen,
    private _statusBar: StatusBar,
    private _iab: InAppBrowser,
    private _store: Store<fromRoot.State>
  ) {
    this._translateService.setDefaultLang("no_nb");
    this._translateService.use("no_nb");
    moment.locale("nb");

    this.platform.ready().then(() => {
      this._statusBar.styleDefault();
      this._translateService.get("BACK").subscribe((res: string) => {
        this._config.set("ios", "backButtonText", res);
      });
    });

    this.sections$ = this._store.select(fromRoot.getSections);
    this.selectedSection$ = this._store
      .select(fromRoot.getSelectedSection)
      .filter(section => !!section);

    this.selectedSection$.first().subscribe(section => {
      this.rootPage = OverviewPage;
      this._splashScreen.hide();
    });

    this.externalLinks$ = this._translateService.get("MENU.EXTERNAL.ITEMS");
    this.contactLinks$ = this._translateService.get("MENU.CONTACT_INFO.ITEMS");
    this.logoLinks$ = this._translateService
      .get("LOGOS")
      .map((res: { [key: string]: { HEADER: string; LIST: string[] } }) => {
        return Object.keys(res).reduce((logos, key) => {
          logos.push({
            header: res[key].HEADER,
            list: res[key].LIST
          });
          return logos;
        }, []);
      });
  }
開發者ID:bGraphic,項目名稱:varsom-hybrid,代碼行數:44,代碼來源:app.component.ts

示例4:

 .map(() =>
   buildOutput$.first(data => data.includes('Chunk Names')).mapTo('webpack')
開發者ID:JinlongHe,項目名稱:kibana,代碼行數:2,代碼來源:watch.ts


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