Files
cell/tests/comments.js

41 lines
822 B
JavaScript

var parseq = use('parseq')
function load_comment_from_api(id)
{
log.console(`Loading comment #${id}`)
return {
id: id,
title: `Comment #${id}`
}
}
/*
only ever expecting a tree in the form
id: number
children:
id: number
...
*/
$_.receiver(tree => {
var requestors = []
for (child of tree.children) {
requestors.push(cb => {
var child_actor = $_.start(undefined, "tests/comments.js")
send(child_actor, child, cb)
})
}
parseq.parallel(requestors, undefined, 10)((results, reason) => {
if (results) {
// All children processed
var comment = load_comment_from_api(tree.id)
var full_comment = {
id: tree.id,
children: children_results
}
send(tree, full_comment)
} else {
send(tree, reason);
}
})
})