How to use the baconjs.constant function in baconjs

To help you get started, we’ve selected a few baconjs 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 mikaelbr / bacon-love / exercises / 10_and_or_or_or_maybe_not / exercise.js View on Github external
expect: function (stream, exercise, assert) {
        stream.onValue(function (report) {
          assert(report !== true);
        });

        c2.push(4000);
      }
    },
    'Should not report if the limit is lower than the flow': {
      input: [
        c3,
        Bacon.constant(false), // inCriticalMode
        Bacon.constant(false), // onBreak
        Bacon.constant(true), // isSingleGate
        Bacon.constant(true), // systemActive
        2000 // riverLimit
      ],

      expect: function (stream, exercise, assert) {
        stream.onValue(function (report) {
          assert(report !== true);
        });

        c3.push(1000);
      }
    },
    'Should not report if the workers are on a break': {
      input: [
        c4,
        Bacon.constant(false), // inCriticalMode
        Bacon.constant(true), // onBreak
github milankinen / ffux / test / state-spec.js View on Github external
      state: (counter) => Bacon.constant(counter)
    })
github milankinen / ffux / test / bacon-take-spec.js View on Github external
    state: (filter) => Bacon.constant(filter)
  })
github milankinen / ffux / test / bacon-actions-spec.js View on Github external
    state: (value) => Bacon.constant(value + 2)
  })
github rbelouin / fip.rbelouin.com / test / js / views / app.spec.jsx View on Github external
function renderApp(p_route, favBus, volBus) {
  var $main = document.createElement("main");
  document.body.appendChild($main);

  favBus = favBus || new Bacon.Bus();
  volBus = volBus || new Bacon.Bus();

  React.render(
    ,
    $main
  );
}
github calmm-js / baret / test / tests.js View on Github external
testRender(<a style="{Bacon.constant({color:" href="#lol">
               {Bacon.constant("Hello")} {Bacon.constant("world!")}
             </a>,
             '<a style="color:red" href="#lol">Hello world!</a>')

  testRender(<div>{Bacon.later(1000,0)}</div>, "")
  testRender(<div>{Bacon.later(1000,0).toProperty(1)}</div>, "<div>1</div>")
  testRender(<div>{Bacon.later(1000,0)} {Bacon.constant(0)}</div>, "")

  const Custom = ({prop, ...props}) =&gt; <div>{`${prop} ${JSON.stringify(props)}`}</div>

  testRender(,
             '<div>Bacon.constant(not-lifted) {}</div>')

  testRender(,
             '<div>lifted {}</div>')

  testRender(,
             '<div>lifted anyway {}</div>')

  const Spread = props =&gt; <div>

  testRender(
               Hello {Bacon.constant("world!")}
             ,
             '<div>Hello world!</div>')

  testRender(<div><div>a</div>{[<div>b</div>, [<div>c</div>, [<div>d</div>]]]}</div>,
             '<div><div>a</div><div>b</div><div>c</div><div>d</div></div>')

  testRender(<div><div>a</div>{[<div>b</div>, Bacon.constant([<div>c</div>, [<div>d</div>]])]}</div>,</div>
github vokkim / tuktuk-chart-plotter / src / client / data-connection.js View on Github external
function connect({providers, settings}) {
  if (providers.length > 1) {
    throw 'Only 1 data provider supported for now'
  }
  if (providers.length === 0) {
    return {
      connectionState: Bacon.constant('disconnected'),
      selfData: Bacon.constant({}),
      aisData: Bacon.constant({})
    }
  }
  const provider = providers[0]
  if (provider.type === 'signalk') {
    return SignalkProvider({address: provider.address, settings})
  } else if (provider.type === 'geolocation') {
    return GeolocationProvider({settings})
  } else {
    throw `Unsupported provider ${provider}`
  }
}
module.exports = connect
github rbelouin / fip.rbelouin.com / src / js / models / storage.js View on Github external
get: function() {
      return Bacon.constant(get(storage, name) || []);
    },
    set: function(songs) {
github milankinen / react-combinators / src / baconjs / combineVDOM.js View on Github external
export default function combineVDOM(vdom) {
  const obs = resolveObservables(vdom, [])
  if (isEmpty(obs)) {
    return Bacon.constant(vdom)
  } else {
    return Bacon
      .combineAsArray(obs)
      .map(values =&gt; assignObservableValues(vdom, zip(obs, values)))
  }

  function resolveObservables(el, obs) {
    const propKeys = Object.keys(el.props || {})
    for (let k = 0 ; k &lt; propKeys.length ; k++) {
      const key = propKeys[k]
      const prop = el.props[key]
      if (key === "children") {
        const children = isArray(prop) ? prop : [ prop ]
        for (let i = 0 ; i &lt; children.length ; i++) {
          const child = children[i]
          if (isObs(child) &amp;&amp; !contains(obs, child)) {