Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
皆さん、こんにちは。
関数を繰り返し呼び出したいのですが、前の呼び出しが完了したときにのみ各呼び出しを実行したかったのです。Async の while は必要なものに適合しますか? それとも、呼び出しは並行して行われますか?
ありがとう!
ゲイリー
必要なことを実行しながら、各機能を連続して実行します。各実行の前に、「テスト」機能を実行して、再度実行する必要があることを確認します。
彼らの例:
var count = 0; async.whilst( function () { return count < 5; }, function (callback) { count++; setTimeout(callback, 1000); }, function (err) { // 5 seconds have passed } );
Chad が指摘したように、Async のwhileは仕事をします。
Async のuntil (while の逆) を検討することをお勧めします。どちらも同じ仕事をしますが、主な違いは次のとおりです。
async.whilst
async.until