Return false does not work then and binds the function to lodash

I use the .then and _.bind in the series. I want to stop the execution of a function (ie) the output of the previous function will be introduced for the next function. Here is my code.

 return getProducts(barcode, sku) .then(_.bind(this.checkForPrice, this)) .then(_.bind(this.addLinkedProducts, this)) .then(null, _.bind(this.handleUnknownError, this)); 

In the checkForPrice function, I use return false to stop execution, as shown below, but this did not stop the thread.

 checkForPrice: function (products) { debugger; if (!products) { return false; } return something; } 

Please help solve this problem.

+6
source share
1 answer

According to @ comment, if I throw an error, it stops the chain.

0
source

Source: https://habr.com/ru/post/1013540/


All Articles