Handling Async calls

Sometimes(probably all the time) you will need to do something async when working with
tasks, jWorkflow provides the ability to control the execution of the workflow via a
baton that is passed to the task

function procrastinate(previous, baton) {
//take the baton, this means the next task will not run until you pass the baton
baton.take();
window.setTimeout(function() {
//do some stuff
//please be nice and always remember to pass the baton!
baton.pass();
}, 1000);
}

If you want to pass a return value to the next task you can pass it along with the
baton.

NOTE: if you did take the baton, the return value from your function will NOT be passed to
the next task:

function awesometown(previous, baton) {
baton.take();
window.setTimeout(function() {
//do stuff
baton.pass(420); //This value will be passed to the next task
}, 100);
return 50; // this will NOT be passed to the next function since you took the baton.
}

the start method provides a callback to execute when the workflow is finished. The final
return value is also passed to the callback:

Canceling Workflows

To cancel the execution of the workflow you can call the drop method on the baton:

function (previous, baton) {
//the value passed to drop will be passed onto the final callback if it exists
baton.drop("I dropped the soap");
//this value will NOT be passed to the next workflow step
return 10;
}