Jockey.on("event-name", function(payload, complete) {
setTimeout(function() { complete(); }, 1000);
// Note: You MUST return false in this case to tell Jockey you plan on calling
// the complete function on your own once events have finished.
return false;
});
The return false hassle can be avoided.
The Jockey code that calls this function literal can detect how many arguments it has (simply f.length).
You could have function(payload){} be treated as sync and function(payload, complete){} be treated as async.
Example from the README:
The
return false
hassle can be avoided.The Jockey code that calls this function literal can detect how many arguments it has (simply
f.length
).You could have
function(payload){}
be treated as sync andfunction(payload, complete){}
be treated as async.Mocha uses this. (See its documentation's Sync and Async sections)