6
我在使用.then
函数和_.bind
函数。我想停止函数的执行,(即)前一个函数的输出是为下一个函数输入的。这是我的代码。返回false不工作,然后用lodash绑定函数
return getProducts(barcode, sku)
.then(_.bind(this.checkForPrice, this))
.then(_.bind(this.addLinkedProducts, this))
.then(null, _.bind(this.handleUnknownError, this));
在checkForPrice
功能,我使用返回false就停止执行下面的一样,但它并没有停止流动。
checkForPrice: function (products) {
debugger;
if (!products) {
return false;
}
return something;
}
请帮助解决此问题。
“停止执行”是什么意思?你有没有尝试抛出一个错误? – thefourtheye
@thefourtheye。我想停止下一个功能。我没有试图抛出错误 – Jegan
返回一个值将简单地落在链中,然后转到下一个处理程序。请尝试抛出一个错误。 – thefourtheye