How to use the baconjs.later 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 rbelouin / fip.rbelouin.com / test / js / models / song.spec.js View on Github external
test("SongModel.fetch fetches songs correctly", withMock(function(t) {
  var p_songs = SongModel.fetch("url", SONG_DURATION / 10)
    .takeUntil(Bacon.later((songs.length + 1) * SONG_DURATION))
    .last();

  p_songs.onValue(function(ss) {
    t.deepEqual(ss.reverse(), _.map(songs, function(song) {
      return _.extend({}, song, {
        favorite: SongModel.isFavorite(song)
      });
    }));
    t.end();
  });
}));
github calmm-js / baret / test / tests.js View on Github external
testRender(<div> {}}
                  style={{display: "block",
                          color: Bacon.constant("red"),
                          background: "green"}}&gt;
               <p>{Bacon.constant(["Hello"])}</p>
               <p>{Bacon.constant(["World"])}</p>
             </div>,
             '<div style="display:block;color:red;background:green"><p>Hello</p><p>World</p></div>')

  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>
</div>
github kefirjs / kefir / test / perf / memory.js View on Github external
createNObservable('Bacon', 700, function(){
  return Bacon.later(0, 1);
})
github CleverCloud / clever-tools / src / models / ws-stream.js View on Github external
.flatMapLatest(() => {
      if (remainingRetryCount === 0) {
        return new Bacon.Error(`WebSocket connection failed ${MAX_RETRY_COUNT} times!`);
      }
      const retryCount = (MAX_RETRY_COUNT - remainingRetryCount + 1);
      Logger.warn(`WebSocket connection closed, reconnecting... (${retryCount}/${MAX_RETRY_COUNT})`);
      return Bacon.later(RETRY_DELAY, null).flatMapLatest(() => {
        return openWsStream({ url, authMessage, startPing, stopPing }, remainingRetryCount - 1);
      });
    });
github CleverCloud / clever-tools / src / commands / service.js View on Github external
function asStream (fn) {
  return Bacon.later(0).flatMapLatest(Bacon.try(fn));
}
github lautis / bacontrap / example / example.js View on Github external
shortcuts.flatMapLatest(function(shortcut) {
    return Bacon.once(shortcut).merge(Bacon.later(2000, "(nothing)"))
  }).onValue(function(text) {
    document.querySelector("#shortcut").textContent = text
github rbelouin / fip.rbelouin.com / src / fip / radio-metadata / index.ts View on Github external
      Bacon.repeat(() =&gt; Bacon.later(interval, true).flatMap(f))
    )
github heikkipora / registry-sync / index.js View on Github external
function fetchUrl(url, bodyIsBinary) {
  if (responseCache[url]) {
    return Bacon.later(0, responseCache[url])
  }

  return Bacon.fromNodeCallback((callback) => {
    request(url, { timeout: 20000, encoding: bodyIsBinary ? null : undefined }, (error, response, body) => {
      if (!error && response.statusCode == 200) {
        if (!url.endsWith('.tgz')) {
          responseCache[url] = body
        }
        callback(null, body)
      } else {
        const statusCode = response ? response.statusCode : 'n/a'
        callback(`Failed to fetch ${url} because of error '${error}' and/or HTTP status ${statusCode}`)
      }
    })
  })
}