-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature(script): $addCallback $finishCallback #591
Conversation
Add manual callback handling, for when you need to `require` other node functions that do not play well with deployd's automatic async callback handling. Call $addCallback() before calling an async function to increment the counter, and $finishCallback() when the callback is finished to decrement the counter. When the counter is 0, deployd will return the response.
655551b
to
ffacf27
Compare
Relevant code snippet for some sort of event: var async = require("async");
$addCallback();
async.each(body.storeData, function (data, done) {
doStuffOnData(data, function (err, result) {
done(err, result);
);
}, function (err){
if (err) return cancel(err);
setResult({done: true});
$finishCallback();
}); |
…ng in deployd's console if callback add/finish happened faster than next process.nextTick.
Thanks for your contribution! Any good way to detect the functions which don't play well with dpd? |
Deployd only attempts to wrap functions that are part of its script domain or script context. Using |
in your snippet
will return cancel be returned on error? how does $finishCallback() get reached? |
Thanks |
@andreialecu you are literally my hero. |
This helps in the 'POST' event also. var createzipfile = require('..createzipfile');
|
Add manual callback handling, for when you need to
require
other node functions that do not play well with deployd's automatic async callback handling.Call
$addCallback()
before calling an async function to increment the counter, and$finishCallback()
when the callback is finished to decrement the counter. When the counter is 0, deployd will return the response.