-
Book Overview & Buying
-
Table Of Contents
JavaScript Design Patterns
By :
A common source of bad performance is running operations sequentially that could be completed in parallel.
For example, a naive implementation of loading a cart and then the contained products would be as follows:
Figure 7.2: Load cart then each of the three products contained from fakestoreapi
In this case, the operation completion time is composed of the sum of the following:
GET /carts/{cartId}GET /products/1GET /products/2GET /products/3There is a requirement for the /products/{productId} calls to be done after the GET /carts/{cartId} call completes since that’s where the product IDs are coming from. What isn’t required is for each product call to wait for the previous one to complete; the calls only depend on data from the GET /carts/{cartId} call. This is an...