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