31 lines
927 B
Plaintext
31 lines
927 B
Plaintext
var parseq = use('parseq', $delay)
|
|
var time = use('time')
|
|
|
|
function load_comment_from_api_requestor(id) {
|
|
return function(cb) {
|
|
return $delay(() => cb({ id, title: `Comment #${id}` }), 0.5)
|
|
// returning the $delay return lets them be cancelled up the chain
|
|
}
|
|
}
|
|
|
|
$receiver(tree => {
|
|
var child_reqs = tree.children.map(child => cb => {
|
|
$start(e => send(e.actor, child, cb), "tests/comments") // Note: recursively calls itself? Original used "tests/comments"
|
|
// We should probably change this to "tests/comments_actor" if it's recursive
|
|
})
|
|
|
|
var job = parseq.par_all({
|
|
comment: load_comment_from_api_requestor(tree.id),
|
|
children: cb => parseq.par_all(child_reqs, /*time*/null, /*thr*/10)(cb)
|
|
})
|
|
|
|
job((result, reason) => {
|
|
if (!result) {
|
|
log.error(reason)
|
|
send(tree, reason)
|
|
}
|
|
|
|
send(tree, { ...result.comment, children: result.children, time: time.text() })
|
|
})
|
|
})
|