<commit_before>import Rx from 'rx';
import Cycle from '@cycle/core';
import {makeDOMDriver, h} from '@cycle/dom';
import {makeHTTPDriver} from '@cycle/http';

import {ifOk, ifError, returnAsObservable} from './helpers/map-errors';

const INGREDIENT_URL = 'http://localhost:4000/api/v1/ingredients/123';

function main({DOM, HTTP}) {
  let request$ = Rx.Observable.just(INGREDIENT_URL);
  let vtree$ = HTTP.filter((res$) => res$.request === INGREDIENT_URL)
        .mergeAll()
        .map((req) => JSON.parse(req.text))
        .map((ing) => ing.data.name)
        .startWith('Loading...')
        .map((ing) => h('p', ing));

  return {
    DOM: vtree$,
    HTTP: request$,
  };
}

Cycle.run(main, {
  DOM: makeDOMDriver('#app', {
    'labeled-slider': require('./components/labeled-slider'),
  }),
  HTTP: makeHTTPDriver(),
});
<commit_msg>Add a slider<commit_after>import Rx from 'rx';
import Cycle from '@cycle/core';
import {makeDOMDriver, h} from '@cycle/dom';
import {makeHTTPDriver} from '@cycle/http';

import {ifOk, ifError, returnAsObservable} from './helpers/map-errors';

const INGREDIENT_URL = 'http://localhost:4000/api/v1/ingredients/123';

function main({DOM, HTTP}) {
  let request$ = Rx.Observable.just(INGREDIENT_URL);
  let vtree$ = HTTP.filter((res$) => res$.request === INGREDIENT_URL)
      .mergeAll()
      .map((req) => JSON.parse(req.text))
      .map((ing) => ing.data.name)
      .startWith('Loading...')
      .map((ing) => h('div', [
          h('p', ing),
          h('input', {type: 'range', min: 0, max: 100, step: 1})
      ]));
  return {
    DOM: vtree$,
    HTTP: request$,
  };
}

Cycle.run(main, {
  DOM: makeDOMDriver('#app', {
    'labeled-slider': require('./components/labeled-slider'),
  }),
  HTTP: makeHTTPDriver(),
});

{'fraction_non_alphanumeric': 0.2002262443438914, 'fraction_numerical': 0.011877828054298642, 'mean_word_length': 3.5358974358974358, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1510332', 'n_tokens_mistral': 645, 'n_tokens_neox': 618, 'n_words': 128}