mw.widgets.APIResultsQueue

API results queue.

Constructor

new mw.widgets.APIResultsQueue(config) #

Parameters:

Name Type Attributes Description
config Object optional

Configuration options

Properties:
Name Type Description
limit number

The default number of results to fetch

threshold number

The default number of extra results that the queue should always strive to have on top of the individual requests for items.

Mixes in:
Source:

Methods

addProvider(provider) #

Add a provider to the group.

Parameters:

Name Type Description
provider mw.widgets.APIResultsProvider

A provider object

Source:
Add a provider to the group.

get(howMany) → {jQuery.Promise} #

Get items from the queue.

Parameters:

Name Type Attributes Description
howMany number optional

How many items to retrieve. Defaults to the default limit supplied on initialization.

Source:

Returns:

Promise that resolves into an array of items.

Type
jQuery.Promise
Get items from the queue.

getLang() → {string|undefined} #

Get language for the query results.

Source:

Returns:

lang Language

Type
string | undefined
Get language for the query results.

getParams() → {Object} #

Get the data parameters sent to the API.

Source:

Returns:

params API search parameters

Type
Object
Get the data parameters sent to the API.

getProviders() → {Array.<mw.widgets.APIResultsProvider>} #

Set the providers.

Source:

Returns:

providers An array of providers

Type
Array.<mw.widgets.APIResultsProvider>
Set the providers.

getQueueSize() → {number} #

Get the queue size.

Source:

Returns:

Queue size

Type
number
Get the queue size.

getThreshold() → {number} #

Get queue threshold.

Source:

Returns:

threshold Queue threshold, below which we will request more items

Type
number
Get queue threshold.

queryProviders(howMany) → {jQuery.Promise} #

Get results from all providers.

Parameters:

Name Type Attributes Description
howMany number optional

How many items to retrieve. Defaults to the default limit supplied on initialization.

Source:

Returns:

Promise that is resolved into an array of fetched items. Note: The promise must have an .abort() functionality.

Type
jQuery.Promise
Get results from all providers.

reset() #

Reset the queue and all its providers.

Source:
Reset the queue and all its providers.

setLang(lang) #

Set language for the query results.

Parameters:

Name Type Description
lang string | undefined

Language

Source:
Set language for the query results.

setParams(params) #

Set the search query for all the providers.

This also makes sure to abort any previous promises.

Parameters:

Name Type Description
params Object

API search parameters

Source:
Set the search query for all the providers.

setProviders(providers) #

Set the providers.

Parameters:

Name Type Description
providers Array.<mw.widgets.APIResultsProvider>

An array of providers

Source:
Set the providers.

setThreshold(threshold) #

Set queue threshold.

Parameters:

Name Type Description
threshold number

Queue threshold, below which we will request more items

Source:
Set queue threshold.

setup() → {jQuery.Promise} #

Set up the queue and its resources. This should be overridden if there are any setup steps to perform.

Source:

Returns:

Promise that resolves when the resources are set up. Note: The promise must have an .abort() functionality.

Type
jQuery.Promise
Set up the queue and its resources.