本文整理匯總了TypeScript中rxjs.Observable類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Observable類的具體用法?TypeScript Observable怎麽用?TypeScript Observable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Observable類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
const project = (value: number, index: number) => Observable.from(Promise.reject('' + value + '-' + index));
示例2: handleObservableError
protected handleObservableError(error: Response | any): Observable<any> {
return Observable.throw(extractError(error));
}
示例3: function
loadData: function(){
return Observable.of({});
},
示例4: get
get(url: string,
options?: RequestOptionsArgs): Observable<Response> {
return Observable.from([this.fakeResponse]);
}
示例5:
/**
* Make Cold observable to Hot observable
*
* On caller function will not need to make ".subscribe(...)" to execute procedure
*
* @param cold Observable
*/
public static makeHot<T>(cold: Observable<T>) {
const subject = new Subject<T>();
cold.subscribe(subject);
return new Observable<T>((observer: any) => subject.subscribe(observer));
}
示例6: publishAll
private publishAll() {
this.getAllSubject.next(
Observable.fromPromise(this.db.getAll())
)
}
示例7:
.catch(() => {
return Observable.throw(LoadError.createGeneralError());
});
示例8: beforeEach
beforeEach(() => {
DevicesService.save.and.returnValue(Observable.of(sensorMock));
DevicesService.update.and.returnValue(Observable.of(sensorMock));
sut.sensor = sensorMock;
});
示例9: constructor
*/
import * as _ from 'lodash';
import { Observable, Subscription } from 'rxjs';
import { CommandType, IAtomNavigation, IImplementationProvider, IImplementationService, Implementation, Reference, navigationHasRange } from 'atom-languageservices';
import { alias, injectable } from 'atom-languageservices/decorators';
import { readFile } from 'fs';
import { ProviderServiceBase } from './_ProviderServiceBase';
import { atomConfig } from '../decorators';
import { AtomCommands } from './AtomCommands';
import { AtomNavigation } from './AtomNavigation';
import { AtomTextEditorSource } from './AtomTextEditorSource';
import { CommandsService } from './CommandsService';
import { ReferenceView } from './views/ReferenceView';
type Location = IAtomNavigation.Location;
const readFile$ = Observable.bindNodeCallback(readFile);
@injectable
@alias(IImplementationService)
@atomConfig({
default: true,
description: 'Adds support for navigate to implementation or implementations'
})
export class ImplementationService
extends ProviderServiceBase<IImplementationProvider, Implementation.IRequest, Observable<Location[]>, Observable<Location[]>>
implements IImplementationService {
private _navigation: AtomNavigation;
private _commands: CommandsService;
private _atomCommands: AtomCommands;
private _source: AtomTextEditorSource;
constructor(navigation: AtomNavigation, commands: CommandsService, atomCommands: AtomCommands, source: AtomTextEditorSource) {