本文整理汇总了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];
}
示例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();
}
示例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;
}, []);
});
}
示例4:
.map(() =>
buildOutput$.first(data => data.includes('Chunk Names')).mapTo('webpack')