0

私は ActionHero async/await の中心となる概念を理解しようとしており、多くの壁にぶつかっています。基本的に、アクションでは、これが 500 ミリ秒後ではなく、すぐに返されるのはなぜですか?

async run (data) {
  setTimeout(() => data.response.outcome = 'success',500)
}

Clarifying edit: this question was more about async execution flow and promise fulfillment than about the literal use of setTimeout(). Its not really specific to ActionHero but that's the pattern AH uses and was my first exposure to the concepts. The answer provided clarifies that some functions have to be wrapped in a promise so they can be await-ed and that there are multiple ways to do that.

4

1 に答える 1