Design pattern for managing multiple asynchronous JavaScript operations

前端 未结 3 1507
暖寄归人
暖寄归人 2020-12-12 16:05

I\'m looking for a good design pattern for keeping track of a bunch of different asynchronous JavaScript activities (images loading, multiple AJAX calls, sequenced AJAX call

3条回答
  •  鱼传尺愫
    2020-12-12 16:34

    Though Promises afford us cleaner code we can do better with Generators. I wrote up a post on how to use Generators in Tame Async JavaScript with ES6. Using the pattern described will make handling complex async interactions easier to reason about and sets up a mental model for await capabilities planned for ES7.

提交回复
热议问题