Documentation
Reference
2.1.50 (current version)
collection
interactivityModel
Interfaces
2.1.51 (release candidate)
collection
interactivityModel
Interfaces

vow.Deferred

A class which describes the deferred objects.

Note.  This class is a part of the Vow library. Only some of the methods are described below. The complete list of methods is available here: http://dfilatov.github.io/vow/. Copyright (c) 2012-2013 Filatov Dmitry (dfilatov@yandex-team.ru). Dual licensed under the MIT and GPL licenses.

Note. It is not a stand-alone module: it is available only if the vow module is connected.

Constructor | Methods

Constructor

vow.Deferred()

Creates a deferred object.

Example:

function someAsyncMethod () {
    var deferred = new ymaps.vow.Deferred(); // or `var deferred = ymaps.vow.defer();`

    doSomeAsyncStuff(function (err, value) {
        if (err) {
            deferred.reject(err);
            return;
        }

        deferred.resolve(value);
    });

    return deferred.promise();
}

someAsyncMethod().then(function (value) {
    console.log('The method result: ' + value);
}, function (err) {
    console.log('Error: ' + err);
});

Methods

NameReturnsDescription
promise()

vow.Promise

Returns the associated promise object.

reject(reason)

Rejects the associated promise object with the specified reason.

resolve(value)

Accepts the associated promise object with the specified value.

Methods details

promise

{vow.Promise} promise()

Returns the associated promise object.

reject

{} reject(reason)

Rejects the associated promise object with the specified reason.

Parameters:

ParameterDefault valueDescription
reason*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Object

The reason for rejection.

* Mandatory parameter/option.

resolve

{} resolve(value)

Accepts the associated promise object with the specified value.

Parameters:

ParameterDefault valueDescription
value*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Object

Value.

* Mandatory parameter/option.