本文整理匯總了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);
}