http://i.stack.imgur.com/9DDQP.png을 기반으로 노드에서 동기화 및 비동기 호출을 파이프 라인 할 수있는 좋은 흐름 라이브러리가 필요합니다.
그런 라이브러리 중 하나는 https://github.com/isaacs/slide-flow-control입니다 (slide preso도보십시오). 필요한 작업은 다음과 같습니다.
자기가 문서화하고있는 것처럼 매우 간결하지만 순수한 nodejs, uml, img 's 등은 필요하지 않습니다.
var chain = require("slide/chain")
, asyncMap = require("slide/async-map")
;
// start processing
main_loop(function() {
console.log("its done"); // when finished
});
function main_loop(cb) {
var res = [];
// each entry in chain below fires sequentially i.e. after
// the previous function completes
chain
([ [start_update_q, "user-foo"]
, [get_followed_users, chain.last]
, [get_favorites, chain.last]
, [calc_new_q]
, [push_results, chain.last]
]
, res
, cb
)
}
function get_favorites(users, cb) {
function fn(user, cb_) {
get_one_users_favorites(user, cb_);
}
// this will run thru get_favorites in parallel
// and after all user favorites are gotten it will fire
// callback cb
asyncMap(users, fn, cb);
}
// code in the various functions in chain here,
// remember to either return the callback on completion.
// or pass it as an arg to the async call you make within the
// function as above i.e. asyncMap will fire cb on completion
그게 내가 찾고 있었던 바로 그 것이다. Seq과 함께 게임을 시작했지만 Node/npm 설치가 중단되었습니다. http://goo.gl/fhilo –