本文整理汇总了TypeScript中rxjs/Observable.Observable类的典型用法代码示例。如果您正苦于以下问题:TypeScript Observable类的具体用法?TypeScript Observable怎么用?TypeScript Observable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Observable类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: return
return (state$: Observable<AppState>) => state$
.select(s => s.cart);
示例2: getBooksAndMovies
// Uses Observable.forkJoin() to run multiple concurrent http.get() requests.
// The entire operation will result in an error state if any single request fails.
getBooksAndMovies() {
return Observable.forkJoin(
this.http.get('/api/books'),
this.http.get('/api/movies')
);
}
示例3:
this.notesDataService.getNotes().mergeMap(notes => Observable.from(notes)).subscribe(note => {
示例4:
getErrorMessage: () => Observable.of('incorrect password'),
示例5: getLang
export function getLang(state$: Observable<IMultilingualState>) {
return state$.select(state => state.lang);
}
示例6: _handleError
/**
* Error handler
* @param error
* @returns { ErrorObservable }
* @private
*/
private _handleError (error: Response) {
let errorMessage = error.text() || 'Server error';
console.error(errorMessage);
return Observable.throw(new Error(errorMessage));
}
示例7:
.catch((error: any) => {
console.error(error);
return Observable.throw(error.json().error || 'Server error');
})
示例9: return
return (state$: Observable<SearchState>) => state$
.select(s => s.loading);
示例10: save
save(entity) {
return Observable.of(entity);
}