Class: FetchManager

low.FetchManager

Class for managing fetch requests.

Some platforms may bail out if a fetch operation is taking too long, which can easily happen if there are requests waiting for their turn in the network queue.

The FetchManager stores waiting requests in an internal queue to keep the network queue clear of waiting requests in order to prevent certain platforms from bailing out.

It also allows you to abort all pending requests at once on platforms providing the AbortController API.

new low.FetchManager (concurrencyLimit)

Name Type Default Description
concurrencyLimit number 4 optional

The maximum amount of simultaneous fetch requests.

Methods

abort ()

Aborts all ongoing and queued fetch requests issued by this FetchManager.

Ongoing requests are only abortable if the environment supports the HTML5 AbortController API.

fetch (url, options)Promise

Fetches data from the given URL.

Name Type Description
url string

The URL from where to fetch from.

options object optional

Optional options to the HTML5 fetch command.

Returns:
Type Description
Promise The fetch Promise object.

fetchPriorized (url, options)Promise

Fetches data from the given URL. The difference to low.FetchManager.fetch is that the fetch operation is handled priorized by being prepended to the front of the fetch queue.

Name Type Description
url string

The URL from where to fetch from.

options object optional

Optional options to the HTML5 fetch command.

Returns:
Type Description
Promise The fetch Promise object.