本文整理匯總了TypeScript中rx.Observable.doOnNext方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Observable.doOnNext方法的具體用法?TypeScript Observable.doOnNext怎麽用?TypeScript Observable.doOnNext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rx.Observable
的用法示例。
在下文中一共展示了Observable.doOnNext方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: matchEvents
return Observable.create((observer: Observer<Object>) => {
const match = events ? matchEvents(events) : null;
const bag = new CompositeDisposable();
const observerables: Observable<any>[] = values(tasks);
let s1: Observable<any>;
let connectables: ConnectableObservable<any>[];
let readyActionObservables: Observable<{type: 'ready'}>[];
if (observerables.length) {
connectables = observerables.map((s) => s.publish());
readyActionObservables =
connectables.map((s) => s.filter(propEq('type', 'ready')));
const allParentsReady: Observable<{type: 'ready'}[]> =
Observable.combineLatest.apply(null, readyActionObservables).take(1);
s1 = allParentsReady;
} else {
s1 = Observable.just(null);
}
if (preStart) {
s1 = s1.flatMap(() => spawn(preStart));
if (match) {
s1 = s1.doOnNext((val: string) => {
const action = match(val);
if (action) {
observer.onNext(action);
}
});
}
}
let input: EventEmitter;
let output: EventEmitter;
bag.add(s1.subscribeOnCompleted(() => {
if (start) {
let s2: Observable<string>;
if (readyActionObservables) {
s2 = Observable
.merge
.apply(null, readyActionObservables)
.startWith(null)
.flatMapLatest(() => spawn(start));
} else {
s2 = spawn(start);
}
let d: Disposable;
if (match) {
d = s2.subscribeOnNext((val) => {
const action = match(val);
if (action) {
observer.onNext(action);
}
});
} else {
d = s2.subscribe(() => {});
}
bag.add(d);
} else { // "process"
input = new EventEmitter();
output = new EventEmitter();
output.on('action', (obj: Object) => {
observer.onNext(obj);
});
process(input, output);
const d = Observable.merge.apply(null, connectables)
.subscribeOnNext((action: Object) => input.emit('action', action));
bag.add(d);
}
}));
if (connectables) {
connectables.forEach((s) => bag.add(s.connect()));
}
return () => {
bag.dispose();
if (input) {
input.removeAllListeners();
}
if (output) {
output.removeAllListeners();
}
};
});