You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 14, 2021. It is now read-only.
Chained Promise: functional programming tools for recurring promises
We often find recurring patterns when handling asynchronous logic with promises, such as an HTTP endpoint that paginates and gives you a URL pointer to the next available dataset.
Chained Promise provides an extended Promise class that you can use to easily abstract out recurring patterns. See jsdocs for more detailed explanations.
Example
Suppose we are querying Wikipedia API to get the list of all linked pages from "Plato" page:
The data field contains the material content of the value, while the next field contains either the promise to the next batch of data, or {[ChainedPromise.DONE]: lastNode} which ChainedPromise recognizes to be the terminal node.
Now that the chaining of the value has been configured, we can work on the series of data.
This executes the given callback function, and the result itself is a promise that resolves into the value of the terminal node when it reaches the end.