How to use the baconjs.combineAsArray 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 zakandrewking / escher / src / Settings.js View on Github external
function convertToConditionalStream (valueStream, statusStream) {
  // Combine values with status to revert to last value when a reject is passed.
  const init = {
    savedValue: null,
    currentValue: null,
    lastStatus: null
  }

  const held = bacon.combineAsArray(valueStream, statusStream.toProperty(null))
        .scan(init, ({ savedValue, currentValue, lastStatus }, [ value, status ]) => {
          // See if the status was just set
          const newStatus = lastStatus !== status

          if (newStatus && status === 'hold') {
            // Record the currentValue as the savedValue
            return {
              savedValue: currentValue,
              currentValue,
              lastStatus: status
            }
          } else if (!newStatus && status === 'hold') {
            // Record the current value, and keep the savedValue unchanged
            return {
              savedValue,
              currentValue: value,
github zakandrewking / escher / src / Settings.js View on Github external
function convertToConditionalStream (valueStream, statusStream) {
  // Combine values with status to revert to last value when a reject is passed.
  const init = {
    savedValue: null,
    currentValue: null,
    lastStatus: null
  }

  const held = bacon.combineAsArray(valueStream, statusStream.toProperty(null))
        .scan(init, ({ savedValue, currentValue, lastStatus }, [ value, status ]) => {
          // See if the status was just set
          const newStatus = lastStatus !== status

          if (newStatus && status === 'hold') {
            // Record the currentValue as the savedValue
            return {
              savedValue: currentValue,
              currentValue,
              lastStatus: status
            }
          } else if (!newStatus && status === 'hold') {
            // Record the current value, and keep the savedValue unchanged
            return {
              savedValue,
              currentValue: value,
github milankinen / react-combinators / examples / 02-todomvc / src / bacon / model.js View on Github external
    items.flatMapLatest(items => Bacon.combineAsArray(
        items.map(item => item.fields.map(".status").map(status => ({status, item})))
    )).toProperty()
github digabi / rich-text-editor / src / clipboard.js View on Github external
() =>
            Bacon.combineAsArray(
                markAndGetInlineImagesAndRemoveForbiddenOnes($editor).map(data =>
                    checkForImageLimit($editor, data, screenshotCountLimit)
                        .doError(() => onValueChanged(SCREENSHOT_LIMIT_ERROR()))
                        .flatMapLatest(() => Bacon.fromPromise(screenshotSaver(data)))
                        .doAction(screenShotUrl => data.$el.attr('src', screenShotUrl))
                        .doError(() => data.$el.remove())
                )
            ).onValue(() => $editor.trigger('input')),
        0
github CleverCloud / clever-tools / spec / application.spec.js View on Github external
it("should be able to create an application for each instance type", function(done) {
    var s_apps = Bacon.combineAsArray(_.map(instanceTypes, function(type) {
      return app.create(api, "My node application", type, "par");
    }));

    s_apps.subscribe(function(event) {
      expect(event.hasValue()).to.equal(true);
      expect(event.value().length).to.equal(instanceTypes.length);
      done();

      return Bacon.noMore;
    });
  });
});
github CleverCloud / clever-tools / src / commands / restart.js View on Github external
.flatMapLatest(([appData, fullCommitId, remoteCommitId]) => {
      const commitId = fullCommitId || remoteCommitId;
      if (commitId != null) {
        const cacheSuffix = withoutCache ? ' without using cache' : '';
        Logger.println(`Restarting ${appData.name} on commit ${colors.green(commitId)}${cacheSuffix}`);
      }
      const s_redeploy = Application.redeploy(api, appData.app_id, appData.org_id, fullCommitId, withoutCache);
      return Bacon.combineAsArray(s_redeploy, appData, remoteCommitId);
    })
    .flatMapLatest(([redeploy, appData, remoteCommitId]) => {
github CleverCloud / clever-tools / src / commands / published-config.js View on Github external
function importEnv (api, params) {
  const { alias } = params.options;

  const s_appData = AppConfig.getAppData(alias);
  const s_vars = variables.readFromStdin();

  const s_result = Bacon.combineAsArray(s_appData, s_vars)
    .flatMapLatest(([appData, vars]) => {
      return PublishedConfig.bulkSet(api, vars, appData.app_id, appData.org_id);
    })
    .flatMapLatest(() => Logger.println('Environment variables have been set'));

  handleCommandStream(s_result);
};
github ayasin / frhttp / lib / frhttp.js View on Github external
process.nextTick(function() {
		var partsStream = makeCandidatePartsStream(candidate).take(1);
		Bacon.combineAsArray(partsStream, graph).map(function (inputs) {
			var walker = inputs[1],
				parts = inputs[0],
				start = parts[0].length ? 0 : '1';
			for (var i=start; i