How to use the rx.Observable.merge function in rx

To help you get started, we’ve selected a few rx 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 laszlokorte / tams-tools / app / components / pla / index.js View on Github external
.distinctUntilChanged(
        (s) => s,
        dimenstionsHaveNotChanged
      )
      // Center the camera vertically and align it to the top
      .map(() => ({weightX: 0.5, weightY: 0})),
  });

  return {
    DOM: O.combineLatest(
      // merge the cost panel into the vtree
      pla$.map(costPanel),
      stage.DOM,
      (a,b) => [a,b]
    ).map(wrapInDiv),
    preventDefault: O.merge([
      actions.preventDefault,
      stage.preventDefault,
    ]),
  };
};
github laszlokorte / tams-tools / app / components / kv / model / index.js View on Github external
const modifiers = (actions) => {
  return O.merge([
    actions.addInput$.map(() =>
      compose(cancelRename, addInput)
    ),
    actions.removeInput$.map(() =>
      compose(cancelRename, removeInput)
    ),
    actions.removeSpecificInput$.map(({inputIndex, reverse}) =>
      compose(cancelRename, removeSpecificInput(inputIndex, reverse))
    ),
    actions.renameInput$.map((inputIndex) => {
      // eslint-disable-next-line no-alert
      const newName = prompt("Rename Input");
      return newName ?
        compose(cancelRename, renameInput(inputIndex, newName)) :
        (s) => s;
    }),
github laszlokorte / tams-tools / app / pages / logic-checker / index.js View on Github external
logicFieldB.output$,
    diff
  );

  const vtree$ = O.combineLatest(
    state$, fieldADOM$, fieldBDOM$,
    render
  );

  return {
    DOM: vtree$,
    preventDefault: O.merge([
      logicFieldA.preventDefault,
      logicFieldB.preventDefault,
    ]),
    autoResize: O.merge([
      logicFieldA.autoResize,
      logicFieldB.autoResize,
    ]),
    insertString: O.merge([
      logicFieldA.insertString,
      logicFieldB.insertString,
    ]),
  };
};
github laszlokorte / tams-tools / app / components / graph / model / index.js View on Github external
),
    actions.doConnectNodes$.map(() => (state) =>
      state.transientEdge && state.transientEdge.toIndex !== null ?
      selectEdge(state.transientEdge, doConnectNodes(state)) :
      doConnectNodes(state)
    ),
    actions.stopConnectNodes$.map(() => (state) => stopConnectNodes(state)),

    actions.autoLayout$.withLatestFrom(props$, (_, {nodeRadius}) => (state) =>
      autoLayout(nodeRadius, state)
    ),

    actions.selectNode$.map((index) => (state) => selectNode(index, state)),
    actions.selectEdge$.map((index) => (state) => selectEdge(index, state)),

    O.merge([
      actions.deselect$ ,
      enabled$.filter((e) => e === false),
    ]).map(() => (state) => deselect(state)),

    actions.removeNode$.map((nodeIndex) => (state) =>
      removeNode(nodeIndex, state)
    ),
    actions.removeEdge$.map((edgeIndex) => (state) =>
      removeEdge(edgeIndex, state)
    ),

    actions.switchMode$.map((mode) => (state) => state.set('mode', mode)),
  ])
  .scan(applyModifier, graphUiState({graph: graphFromJson({})}))
  .map(applyPartialNodeMovement)
  .combineLatest(props$, enabled$, (state, props, enabled) =>
github freeCodeCamp / freeCodeCamp / client / sagas / gitter-saga.js View on Github external
export default function gitterSaga(actions$, getState, { document }) {
  const helpToggleProxy = new Subject();
  const {
    mainChat,
    toggle$: mainChatToggle$
  } = createMainChat(getState, document);
  return Observable.merge(
    mainChatToggle$,
    helpToggleProxy,
    actions$
      .filter(({ type }) => (
        type === types.openMainChat ||
        type === types.closeMainChat ||
        type === types.toggleMainChat ||
        type === types.toggleHelpChat
      ))
      .map(({ type }) => {
        const state = getState();
        let shouldBlur = false;
        if (type === types.toggleHelpChat) {
          const {
            app: { isHelpChatOpen },
            challengesApp: { helpChatRoom }
github laszlokorte / tams-tools / app / components / kv / intent / loops.js View on Github external
.events('touchstart'),
    DOM
      .select('.kv-cell-atom[data-edit="loops"][data-kv-cell]')
      .events('mousedown'),
  ]).share();

  const pointerDown$ = pointerDownEvent$
    .map((evt) => ({
      allOutputs: !evt.altKey,
      cell: BitSet(evt.ownerTarget.dataset.kvCell),
      output: parseInt(evt.ownerTarget.dataset.kvOutput, 10),
    }))
    .filter(({cell}) => cell !== null)
    ;

  const pointerUp$ = O.merge([
    touchEnd$,
    mouseUp$,
  ]);

  const drag$ = pointerDown$
    .map(({cell, output, allOutputs}) =>
      O.just({
        allOutputs,
        output: output,
        startCell: cell,
        targetCell: cell,
      }).concat(
        pointerEnter$
        .filter(({cell: c}) => c !== null)
        .distinctUntilChanged(
          ({cell: c}) => c,
github alkhe / electron-cycle-media / src / mediadriver.js View on Github external
const makeCommand$ = controls =>
	$.merge(...Object.keys(controls)
		.map(name =>
			controls[name].map(value => ({ name, value }))
	))
github laszlokorte / tams-tools / app / components / spinner / intent.js View on Github external
export default (DOM) => {
  const incButton = DOM.select('[data-increment]');
  const decButton = DOM.select('[data-decrement]');

  const incClick$ = incButton.events('click');
  const decClick$ = decButton.events('click');

  return {
    increment$:
      incClick$
      .map(() => true),
    decrement$:
      decClick$
      .map(() => true),
    preventDefault: O.merge(
      incClick$,
      decClick$,
      decButton.events('mousedown'),
      incButton.events('mousedown')
    ).share(),
  };
};
github freeCodeCamp / freeCodeCamp / common / app / routes / Challenges / redux / completion-epic.js View on Github external
Observable.defer(() => {
      const body = { ...challengeInfo, _csrf };
      const saveChallenge = postJSON$(url, body)
        .retry(3)
        .map(({ points, lastUpdated, completedDate }) =>
          submitChallengeComplete(
            username,
            points,
            { ...challengeInfo, lastUpdated, completedDate }
          )
        )
        .catch(createErrorObservable);
      const challengeCompleted = Observable.of(moveToNextChallenge());
      return Observable.merge(saveChallenge, challengeCompleted)
        .startWith({ type: types.submitChallenge.start });
    }),
    Observable.of(moveToNextChallenge())
github JulienPradet / pigment-store / src / core / generator / js / bundler / browserify / index.js View on Github external
const bundler = (testDir, styleguideDir, options) => (appIndexFile$, iframeIndexFile$) => {
  const compiledAppFile$ = appIndexFile$
    .map(fileToReadableStream)
    .map(configCompiler(testDir, styleguideDir, options, 'app'))
    .flatMap(render(testDir, styleguideDir, options))

  const compiledIframeFile$ = iframeIndexFile$
    .map(fileToReadableStream)
    .map(configCompiler(testDir, styleguideDir, options, 'iframe'))
    .flatMap(render(testDir, styleguideDir, options))

  if (options.dev) {
    return serve(testDir, styleguideDir, options)(compiledAppFile$, compiledIframeFile$)
  } else {
    return Observable.merge(
      compiledAppFile$.flatMap((file) => writefile(
        path.join(styleguideDir, 'app.js'),
        file
      )),
      compiledIframeFile$.flatMap((file) => writefile(
        path.join(styleguideDir, 'iframe.js'),
        file
      ))
    )
  }
}