Some checks failed
Build and Deploy / build-macos (push) Failing after 4s
Build and Deploy / build-windows (CLANG64) (push) Has been cancelled
Build and Deploy / package-dist (push) Has been cancelled
Build and Deploy / deploy-itch (push) Has been cancelled
Build and Deploy / deploy-gitea (push) Has been cancelled
Build and Deploy / build-linux (push) Has been cancelled
41 lines
822 B
JavaScript
41 lines
822 B
JavaScript
var parseq = use('parseq')
|
|
|
|
function load_comment_from_api(id)
|
|
{
|
|
console.log(`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);
|
|
}
|
|
})
|
|
}) |