How to use the baconjs.Bus 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 CleverCloud / clever-tools / src / models / log.js View on Github external
.toProperty();

  const s_appLogs = Application.get(api, appData.app_id)
    .flatMapLatest((app) => {
      Logger.debug('Fetch application logs…');
      if (deploymentId != null) {
        return getAppLogs(app.id, null, null, new Date(), null, deploymentId);
      }
      return s_deploymentStart.flatMapLatest((deploymentStartEvent) => {
        const deploymentId = deploymentStartEvent.data.uuid;
        return getAppLogs(app.id, null, null, new Date(), null, deploymentId);
      });
    });

  // TODO, could be done without a Bus (with merged streams)
  const s_allLogs = new Bacon.Bus();

  s_deploymentStart.onValue(() => {
    s_allLogs.push(colors.bold.blue('Deployment started'));
  });

  s_deploymentEnd.onValue((e) => {
    if (e.data.state === 'OK') {
      s_allLogs.push(colors.bold.green('Deployment successful'));
    }
    else {
      s_allLogs.error('Deployment failed. Please check the logs');
    }
    s_allLogs.end();
  });

  if (!quiet) {
github viddo / atom-textual-velocity / spec / logger-spec.js View on Github external
beforeEach(function () {
      this.filesBus = new Bacon.Bus()
      this.initialPathScanDoneBus = new Bacon.Bus()

      const filesProp = this.filesBus.toProperty()
      const initialPathScanDoneProp = this.initialPathScanDoneBus.map(true).toProperty(false)

      this.prevCallsLength = this.consoleSpy.log.calls.length // to compensate for console logs done previously

      this.logger.logPathScan({filesProp: filesProp, initialPathScanDoneProp: initialPathScanDoneProp})
      R.times((i) => { this.filesBus.push(R.repeat(`file ${i}`, i)) }, 5)
    })
github crucialfelix / supercolliderjs / packages / dryadic-supercollider / src / __tests__ / SynthStream.spec.ts View on Github external
describe("SynthStream", function() {
  const stream = new Bus();
  const properties = {
    stream,
  };
  const ss = new SynthStream(properties);

  it("should construct", function() {
    expect(ss).toBeTruthy();
  });

  describe("commandsForEvent", function() {
    it("has 1 message with no event.id supplied", function() {
      const event = {
        type: "noteOn",
        defName: "sin",
        args: {},
      };
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 mikaelbr / bacon-love / exercises / 06_map_and_filter / exercise.js View on Github external
var verify = require('../../verify.js');
var Bacon = require('baconjs');
var _ = require('lodash');

var zrrkShip = {type: "zrrk"};
var purpleShip = {type: "purple"};
var earthianShip = {type: "earthian"};
var martianShip = {type: "martian"};

var threats = ['low', 'low', 'medium', 'high', 'extreme', 'extreme'];

var shipSensor1 = new Bacon.Bus();
var shipSensor2 = new Bacon.Bus();
var shipSensor3 = new Bacon.Bus();
var destroyerDistanceStream1 = new Bacon.Bus();
var destroyerDistanceStream2 = new Bacon.Bus();
var destroyerDistance;

var shipSensorR = new Bacon.Bus();
var destroyerDistanceStreamR = new Bacon.Bus();

var run = {
  input: [shipSensorR, destroyerDistanceStreamR.toProperty(8)],
  expect: function (streams, ex, assert) {
    var a = streams.ships
      .fold(0, function (acc, v) { return acc + v; });

    var b = streams.threat.changes()
      .fold([], '.concat');

    var c = streams.postArrivalShips
github SignalK / signalk-server-node / src / streambundle.js View on Github external
function StreamBundle(selfId) {
  this.selfContext = 'vessels.' + selfId
  this.buses = {}
  this.allPathsBus = new Bacon.Bus()
  this.selfBuses = {}
  this.selfAllPathsBus = new Bacon.Bus()
  this.selfStreams = {}
  this.selfAllPathsStream = new Bacon.Bus()
  this.keys = new Bacon.Bus()
  this.availableSelfPaths = []
}
github ayasin / frhttp / samples / inject.js View on Github external
.when('makes another bus', [], ['anotherBus'], function(producer) {
				producer.value('anotherBus', new Bacon.Bus());
				return producer.done();
			})
			.render(['theBus'], function (writer, input) {
github lhahne / trains / actions / LiveDataActions.js View on Github external
'use strict'

var Bacon = require('baconjs')

module.exports = {
  station: new Bacon.Bus(),
  trainListDidMount: new Bacon.Bus()
}
github viddo / atom-textual-velocity / spec / interactor-spec.js View on Github external
beforeEach(function () {
    spyOn(Date, 'now').andReturn(0)
    buses = {
      abortEditCellS: new Bacon.Bus(),
      activePathS: new Bacon.Bus(),
      clickedCellS: new Bacon.Bus(),
      dblClickedCell: new Bacon.Bus(),
      editCellS: new Bacon.Bus(),
      initialScanDoneP: new Bacon.Bus(),
      keyDownS: new Bacon.Bus(),
      keyEnterS: new Bacon.Bus(),
      keyEscS: new Bacon.Bus(),
      keyUpS: new Bacon.Bus(),
      listHeightS: new Bacon.Bus(),
      newFilenameS: new Bacon.Bus(),
      rowHeightS: new Bacon.Bus(),
      saveEditedCellContentS: new Bacon.Bus(),
      scrollTopS: new Bacon.Bus(),
      sessionStartS: new Bacon.Bus(),
      sifterP: new Bacon.Bus(),
      sortDirectionS: new Bacon.Bus(),
      sortFieldS: new Bacon.Bus(),
      textInputS: new Bacon.Bus()
    }

    const viewCtrl = {
      abortEditCellS: buses.abortEditCellS,
      activePathS: buses.activePathS,
      clickedCellS: buses.clickedCellS,
      dblClickedCellS: buses.dblClickedCell,
      keyDownS: buses.keyDownS,
github experimentalDataAesthetics / play-splom / app / sound / SoundApp.js View on Github external
constructor(log) {
    this.synthStream = new Bacon.Bus();
    this.masterControlStream = new Bacon.Bus();
    this.loopModeEventStream = new Bacon.Bus();
    this.playing = false;
    this.log = log;
    this.watchingDirectory = undefined;

    this.masterArgs = {
      amp: 0.3
    };
  }