How to use the @reactivex/rxjs.Observable.merge function in @reactivex/rxjs

To help you get started, we’ve selected a few @reactivex/rxjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github machinelabs / machinelabs / server / src / util / process.ts View on Github external
let stdOutStream = Observable
                        .fromEvent(process.stdout, 'data')
                        .map(mapFrom('stdout'))
                        .share();

    // Since STDERR is a stream just like STDOUT it doesn't
    // really work to propagate that with Observable/error.
    // Instead we combine STDOUT and STDERR to one stream.
    let stdErrStream = Observable
                        .fromEvent(process.stderr, 'data')
                        .map(mapFrom('stderr'))
                        .share();

    let closeStream = Observable.fromEvent(process, 'close').share();

    return Observable.merge(stdOutStream, stdErrStream).takeUntil(closeStream);
  }
github sourcegraph / javascript-typescript-langserver / src / typescript-service.ts View on Github external
								.mergeMap(packageJsonUri => Observable.merge(
									castArray(this.projectManager.getParentConfiguration(packageJsonUri) || []),
									// Search child directories starting at the directory of the package.json
									observableFromIterable(this.projectManager.getChildConfigurations(url.resolve(packageJsonUri, '.')))
								))
							// Else search all tsconfigs in the workspace
github giltig / rxfrf / src / shared / stores / counterStore.js View on Github external
import {Actions, dispatch} from 'shared/actions'
import {add} from 'ramda'
import combineLatestObj from 'shared/utils/combineLatestObj'

/* ========================== state ========================================= */

const increase =
  getPayload(Actions.COUNTER_INCREASED)
    .mapTo(1)

const decrease =
  getPayload(Actions.COUNTER_DECREASED)
    .mapTo(-1)

export const count =
  Observable
    .merge(increase, decrease)
    .scan(add)
    .startWith(0)

/* ========================== handlers ====================================== */

export const increaseCount =
  Observable.of(() => {
    dispatch(Actions.COUNTER_INCREASED)
  })

export const decreaseCount =
  Observable.of(() => {
    dispatch(Actions.COUNTER_DECREASED)
  })
github machinelabs / machinelabs / server / src / statistics / usage-statistic.service.ts View on Github external
getStatistic(userId: string, year: number, month: ShortMonth): Observable {

    let executions$ = Observable.merge(
      dbRefBuilder.userExecutionsByMonthRef(userId, year, month).onceValue(),
      dbRefBuilder.userExecutionsLiveRef(userId).onceValue()
      )
      .map(snapshot => snapshot.val())
      .map(val => val ? Object.keys(val) : [])
      .flatMap(executionIds => Observable.from(executionIds)
                                         .flatMap(id => dbRefBuilder.executionRef(id).onceValue()))
      .map(snapshot => snapshot.val())
      .filter(execution => execution !== null);

    return this.costCalculator.calc(executions$)
                              .map(costReport => ({
                                  costReport: costReport,
                                  secondsLeft: FREE_MONTHLY_COMPUTATION_SECONDS - costReport.totalSeconds
                                }));
  }