How to use the baconjs.zipAsArray 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 / unit / controllers / song.spec.js View on Github external
}
  };

  const songs = [
    {
      id: "ONE"
    },
    {
      id: "TWO"
    },
    {
      id: "THREE"
    }
  ];

  Bacon.zipAsArray(songs.map(_.partial(searchOnSpotify, Spotify))).subscribe(
    function(ev) {
      expect(ev.hasValue()).toBeTruthy();

      expect(ev.value()).toStrictEqual([
        {
          id: "ONE",
          spotify: null,
          spotifyId: null
        },
        {
          id: "TWO",
          spotify: "https://open.spotify.com/2",
          spotifyId: "2"
        },
        {
          id: "THREE",
github rbelouin / fip.rbelouin.com / test / unit / controllers / song.spec.js View on Github external
token_type: "type"
  });

  const data = getFipSongLists(
    Fip,
    Spotify,
    wsPath,
    ["radio1", "radio2"],
    p_token
  );

  const p_radio1 = data.radio1.fold([], (items, item) => items.concat([item]));

  const p_radio2 = data.radio2.fold([], (items, item) => items.concat([item]));

  Bacon.zipAsArray([p_radio1, p_radio2]).subscribe(function(ev) {
    expect(ev.hasValue()).toBeTruthy();

    const [radio1, radio2] = ev.value();

    expect(radio1).toStrictEqual([
      [],
      [
        {
          type: "song",
          song: {
            id: "ONE",
            spotify: null,
            spotifyId: null
          }
        }
      ],
github rbelouin / fip.rbelouin.com / src / js / controllers / song.js View on Github external
export function setFavoriteSongs(syncs, songs) {
  if (typeof ga === "function") {
    ga(
      "send",
      "event",
      "favorites",
      "syncs",
      syncs.length > 1 ? "With Spotify" : "Without Spotify",
      songs.length
    );
  }

  return Bacon.zipAsArray(_.map(syncs, sync => sync.set(songs)));
}
github rbelouin / fip.rbelouin.com / src / js / controllers / song.js View on Github external
export function getFavoriteSongs(syncs) {
  const p_songLists = Bacon.zipAsArray(
    _.map(syncs, sync => sync.get())
  ).toProperty();

  return p_songLists
    .map(function(songLists) {
      const songs = _.flatten(songLists);
      return _.uniqBy(songs, song => song.spotifyId);
    })
    .toProperty();
}
github skellyb / fluxstream / lib / store.js View on Github external
Store.prototype.combineOnce = function(streams, callback) {
        return Bacon.zipAsArray(streams).onValue(function(combo) {
            callback(combo);
            return Bacon.noMore;
        });
    }
github lhahne / trains / front / index.js View on Github external
componentDidMount: function() {
    this.unsubscribe =
      Bacon.zipAsArray(StationDataStore.stationArrivalView, StationMetadataStore.stationsByCode)
      .onValues((stationView, stationCodes) => {
        this.stationCodes = stationCodes
        this.setState({
          stationView: stationView
        })
      })

    LiveDataActions.trainListDidMount.onValue(() => LiveDataActions.station.push('TPE'))
    LiveDataActions.trainListDidMount.push(true)
  },
github lhahne / trains / components / TrainList.js View on Github external
componentDidMount: function() {
    this.unsubscribe =
      Bacon.zipAsArray(StationDataStore.stationArrivalView, StationMetadataStore.stationsByCode)
      .onValues((stationView, stationCodes) => {
        this.stationCodes = stationCodes
        this.setState({
          dataSource: this.state.dataSource.cloneWithRows(stationView),
        })
      })
    LiveDataActions.trainListDidMount.push(true)
  },
github skellyb / fluxstream / lib / store.js View on Github external
Store.prototype.combine = function(streams, callback) {
        return Bacon.zipAsArray(streams).onValue(callback);
    };
github lhahne / trains / stores / StationMetadataStore.js View on Github external
var stations = Bacon.fromPromise(fetch(METADATA_URL))
  .flatMap(response => Bacon.fromPromise(response.json()))
  .toProperty()

var stationsByCode = stations.map(stations =>
  _(stations)
    .map(station => {
      station.stationName = station.stationName.replace(' asema', '')
      return station
    })
    .indexBy('stationShortCode')
    .value()
)

var metadataForStation =
  Bacon.zipAsArray(stationsByCode, LiveDataActions.station)
  .map(params => {
    [stations, station] = params
  })

module.exports = {
  stations: stations,
  stationsByCode: stationsByCode
}
github mikaelbr / bacon-love / exercises / 06_map_and_filter / exercise.js View on Github external
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
      .fold(0, function (acc, v) { return acc + v; });

    var all = Bacon.zipAsArray(a,b,c)
      .onValues(function (ships, threat, postArrivalShips) {
        return assert(ships === 3 && _.isEqual(threat, threats) && postArrivalShips == 2);
      });

    shipSensorR.push(zrrkShip);
    destroyerDistanceStreamR.push(8);
    destroyerDistanceStreamR.push(7);
    destroyerDistanceStreamR.push(4);
    destroyerDistanceStreamR.push(2);
    destroyerDistanceStreamR.push(0.5);
    destroyerDistanceStreamR.push(0);
    shipSensorR.push(earthianShip);
    shipSensorR.push(zrrkShip);
    shipSensorR.push(zrrkShip);
    destroyerDistanceStreamR.end();
    shipSensorR.end();