Defined the logic that is invoked when batch have been cancelled.
import Batch = require("nativescript-batch");
var b = Batch.newBatch(function(ctx) {
ctx.value = 1;
}).then(function(ctx) {
ctx.value = 2;
ctx.cancel();
}).then(function(ctx) {
ctx.value = 3; // will not be invoked
}).then(function(ctx) {
ctx.value = 4; // will not be invoked
});
b.batch.whenCancelled(function(ctx) {
console.log("Value: " + ctx.value); // 2
});
b.start();