How to use the baconjs.once 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 / src / js / models / spotify.js View on Github external
return send(req).flatMapLatest(function(res) {
    return Bacon.once(res).merge(
      res.next ? fetchAndFollow(send, token, res.next) : Bacon.never()
    );
  });
}
github CleverCloud / clever-tools / src / models / application.js View on Github external
return s_types.flatMapLatest(function (types) {
    const enabledTypes = _.filter(types, (t) => t.enabled);
    const matchingVariants = _.filter(enabledTypes, (t) => t.variant && t.variant.slug === type);
    const instanceVariant = _.sortBy(matchingVariants, 'version').reverse()[0];
    return instanceVariant ? Bacon.once(instanceVariant) : new Bacon.Error(type + ' type does not exist.');
  });
};
github CleverCloud / clever-tools / src / models / application.js View on Github external
const s_app = s_apps.flatMapLatest(function (apps) {
    const filtered_apps = _.filter(apps, function (app) {
      return app.name === name;
    });
    if (filtered_apps.length === 1) {
      return Bacon.once(filtered_apps[0]);
    }
    else if (filtered_apps.length === 0) {
      return Bacon.once(new Bacon.Error('Application not found'));
    }
    else {
      return Bacon.once(new Bacon.Error('Ambiguous application name'));
    }
  });
github vokkim / tuktuk-chart-plotter / src / server / server.js View on Github external
.flatMapError(err => {
      if (err.code === 'ENOENT') {
        console.log('No client config file found')
        return Bacon.once({})
      } else {
        console.error('Error loading client config file: ', err)
        return Bacon.once({})
      }
    })
  clientConfig.onValue(config => {
github CleverCloud / clever-tools / src / models / addon.js View on Github external
return s_addons.flatMapLatest((addons) => {
    const filtered_addons = _.filter(addons, ({ name, realId }) => {
      return name === addonName || realId === addonName;
    });
    if (filtered_addons.length === 1) {
      return Bacon.once(filtered_addons[0]);
    }
    if (filtered_addons.length === 0) {
      return Bacon.once(new Bacon.Error('Addon not found'));
    }
    return Bacon.once(new Bacon.Error('Ambiguous addon name'));
  });
}
github CleverCloud / clever-tools / spec / application.app.js View on Github external
return Bacon.once("Missing description.");
  }
  else if(!app.instanceType) {
    return Bacon.once("Missing instance type.");
  }
  else if(!app.instanceVersion) {
    return Bacon.once("Missing instance version.");
  }
  else if(_.every(flavors, function(flavor) { return flavor.name != app.maxFlavor; })) {
    return Bacon.once("Invalid max flavor.");
  } 
  else if(_.every(flavors, function(flavor) { return flavor.name != app.minFlavor; })) {
    return Bacon.once("Invalid min flavor.");
  } 
  else if(!app.maxInstances || !app.minInstances) {
    return Bacon.once("Missing scaling configuration.");
  }
  else if(!app.name) {
    return Bacon.once("Missing name.");
  }
  else if(app.zone != "mtl" || app.zone != "par") {
    return Bacon.once("Invalid zone.");
  }
  else {
    return Bacon.once({
      "id": "app_313f9890-6a7b-4267-8afb-1b346930382a",
      "name": app.name,
      "description": app.description,
      "zone": app.zone,
      "instance": {
        "type": app.instanceType,
        "version": app.instanceVersion,
github heikkipora / registry-sync / index.js View on Github external
.flatMap(function(distribution) {
             if (binaryExists(distribution)) {
               return Bacon.once('Already downloaded ' + distribution.name + '@' + distribution.version)
             }
             return fetchBinary(distribution.dist)
                      .doAction(function(data) {
                        if (sha1(data) != distribution.dist.shasum) {
                          throw new Error('SHA checksum of ' + distribution.name + '@' + distribution.version + ' does not match')
                        }
                        fs.writeFileSync(packageBinaryFilePath(distribution.name, distribution.version), data)
                      })
                      .map('Downloaded ' + distribution.name + '@' + distribution.version)
           })
}
github CleverCloud / clever-tools / spec / application.app.js View on Github external
return Bacon.once("Missing instance type.");
  }
  else if(!app.instanceVersion) {
    return Bacon.once("Missing instance version.");
  }
  else if(_.every(flavors, function(flavor) { return flavor.name != app.maxFlavor; })) {
    return Bacon.once("Invalid max flavor.");
  } 
  else if(_.every(flavors, function(flavor) { return flavor.name != app.minFlavor; })) {
    return Bacon.once("Invalid min flavor.");
  } 
  else if(!app.maxInstances || !app.minInstances) {
    return Bacon.once("Missing scaling configuration.");
  }
  else if(!app.name) {
    return Bacon.once("Missing name.");
  }
  else if(app.zone != "mtl" || app.zone != "par") {
    return Bacon.once("Invalid zone.");
  }
  else {
    return Bacon.once({
      "id": "app_313f9890-6a7b-4267-8afb-1b346930382a",
      "name": app.name,
      "description": app.description,
      "zone": app.zone,
      "instance": {
        "type": app.instanceType,
        "version": app.instanceVersion,
        "minInstances": app.maxInstances,
        "maxInstances": app.minInstances,
        "maxAllowedInstances": 40,
github CleverCloud / clever-tools / spec / application.app.js View on Github external
"price": 3.4364000000,
    "available": true
  }, {
    "name": "XL",
    "mem": 16384,
    "cpus": 8,
    "disk": null,
    "price": 6.8729000000,
    "available": true
  }];

  if(app.deploy != "git") {
    return Bacon.once("The deployment type has to be git.");
  }
  else if(!app.description) {
    return Bacon.once("Missing description.");
  }
  else if(!app.instanceType) {
    return Bacon.once("Missing instance type.");
  }
  else if(!app.instanceVersion) {
    return Bacon.once("Missing instance version.");
  }
  else if(_.every(flavors, function(flavor) { return flavor.name != app.maxFlavor; })) {
    return Bacon.once("Invalid max flavor.");
  } 
  else if(_.every(flavors, function(flavor) { return flavor.name != app.minFlavor; })) {
    return Bacon.once("Invalid min flavor.");
  } 
  else if(!app.maxInstances || !app.minInstances) {
    return Bacon.once("Missing scaling configuration.");
  }
github CleverCloud / clever-tools / src / models / addon.js View on Github external
function getId (api, orgaId, addonIdOrName) {
  if (addonIdOrName.addon_id) {
    return Bacon.once(addonIdOrName.addon_id);
  }
  return getByName(api, orgaId, addonIdOrName.addon_name)
    .map((addon) => addon.id);
}