本文整理汇总了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) {