back to Overview

promise.always()

Registers a callback that will always be called when the Promise's operation ended, no matter whether the operation succeeded or not.
Complete distribution only, not available in stand-alone modules.

Syntax

promise.always(callback)

Parameters

callback
a function to be called when the operation has been finished, no matter what its result was. The exact arguments depend on the operation and may vary depending on whether it succeeded or not. If the function returns a Promise, that Promise will be evaluated to determine the state of the returned Promise. If provided and it returns regularly, the returned promise will have success status. If it throws an error, the returned Promise will be in the error state.
(return value)
a new Promise object. Its state is determined by the callback.

Description

Registers a callback that will always be called when the Promise's operation ended, no matter whether the operation succeeded or not. This is a convenience function that will call then() with the same function for both arguments. It shares all of its semantics.

Example

Simple handler for a HTTP request.

$.request('get', '/weather.html')
    .always(function() {
       alert('Got response or error!');
    });

Comments

comments powered by Disqus

back to Overview

Functions