Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 17x 17x 36x 93x 93x 30x 36x 27x 9x | import { empty, merge, Observable, queueScheduler, Subject } from 'rxjs'; import { mergeMap, observeOn, subscribeOn } from 'rxjs/operators'; import { Store } from './Store'; import { Action, Deps } from './types'; export function createOutputStream( action$: Subject<Action>, stores: Store[] ): Observable<Action> { const deps = { action$: action$ as Deps['action$'] }; return action$.pipe( subscribeOn(queueScheduler), observeOn(queueScheduler), mergeMap(sourceAction => { const handlers = stores .map(store => store.getOutputStream(sourceAction, deps)) .filter(handler => handler !== null) .reduce((ret, arr) => [...ret, ...arr], [])!; if (handlers.length === 0) { return empty(); } else { return merge(...handlers); } }) ); } |