JavaScript Promise Asynchronous Implementation section download display

Source: Internet
Author: User

Links:

JavaScript Promise: Introduction

1. Chapter One chapter sequence download display
Use Array.reduce () and Promise.resolve () to concatenate the download and display of each chapter together as a whole.
Download [Display] concatenation again.
Promise.resolve (). [Then () and then ()]. [Then () and then ()] .... + = Series
2. After each chapter has been downloaded, the chapter shows
Use Array.map () to parallel the download of each chapter, using Promise.all () to merge the results in one place, and then cycle through the chapters in a chapter. [DOWNLOAD] First parallel and then in series with [display]
Promise.all () = Parallel
3. Each chapter is downloaded separately, and the download is displayed consecutively in the order of chapters. If the section you want to display is not finished downloading, wait.
Use Array.map () to parallel the download of each chapter and then use Promise.resolve () to concatenate the [display] of each chapter.
Story.chapterUrls.map (Getjson) + parallel download
Promise.resolve (). [Then ()]. [Then ()]. [Then ()]

Parallelism is done sequentially by looping through the array of Getjson.

The serial is implemented by promise then, only the previous step and then the next one is done.

JavaScript Promise Asynchronous Implementation section download display

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.