node.js - Bluebird - how to break promise chain early -


promisea().then(function(dataa){     if (dataa.foo == "skip me")         return ?? //break promise - don't perform next then()     else         return promiseb() }).then(function(datab){     console.log(datab) }).catch(function (e) {     //optimal solution not cause method invoked }) 

how can above code modified break (skip 2nd then())?

bluebird allows cancel promise:

var promise = require('bluebird'); promise.config({     // enable cancellation     cancellation: true, });  // store promise var p = promisea().then(function(dataa){     if (dataa.foo == "skip me")         p.cancel(); // cancel when needed     else         return promiseb(); }).then(function(datab){     console.log(datab); }).catch(function (e) {     //optimal solution not cause method invoked }); 

Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -