Expand all

mw.echo.api.PromisePrioritizer

Constructor

new mw.echo.api.PromisePrioritizer() #

Promise prioritizer for API actions. The prioritizer takes a promise at a time, always prioritizing the latest promise and aborting and ignoring the others.

This allows us to send multiple promises in quick successions but trust that we get back only the latest successful request.

Source:
Promise prioritizer for API actions.

Methods

prioritize(promise) → {jQuery.Promise} #

Prioritize a promise

Parameters:

Name Type Description
promise jQuery.Promise | Promise

Promise

Source:

Returns:

The main deferred object that resolves or rejects when the latest promise is resolved or rejected.

Type
jQuery.Promise
Prioritize a promise

setFailure(promise) #

Set failure for the promise. Reject the main deferred object only if we are dealing with the currently prioritized promise.

Parameters:

Name Type Description
promise jQuery.Promise

The promise that failed. The main deferred object is rejected with the result of the latest prioritized promise

Source:
Set failure for the promise.

setSuccess(promise) #

Set success for the promise. Resolve the main deferred object only if we are dealing with the currently prioritized promise.

Parameters:

Name Type Description
promise jQuery.Promise

The promise that resolved successfully. The main deferred object is resolved with the result of the latest prioritized promise.

Source:
Set success for the promise.