Ext.ux.Deferred icon indicating copy to clipboard operation
Ext.ux.Deferred copied to clipboard

rejecting outside of async function

Open ahj opened this issue 12 years ago • 2 comments

I know you specifically state the class is for handling Async functions but I just ran in to this issue...

function aSync (val) {
    var dfd = Ext.create ('Ext.ux.Deferred') ,
          task;

    if (val == 0)
        dfd.reject('val cannot be zero!');

    task = setInterval (function () {
        // here your async task
        clearInterval (task);
    }, 1000);

    return dfd;
}

aSync (0).fail (function (result) {
    // this never gets called
});

I worked around it by wrapping the dfd.reject in a very short setTimeout. Is there another way of doing this?

ahj avatar Apr 03 '14 14:04 ahj

First of all, thanks for this issue!

Now, try again with the new version 0.1.0 and please give me a feedback ;)

Wilk

wilk avatar May 25 '14 03:05 wilk

Hi!

Got a similar issue here so maybe no need to open a new ticket. See the simplified example below. In real life I have a mix of async/sync paths within the deferred body. I get an error "TypeError: this.internalPromise is null" once I do:

function myPromise() {
    var dfd = Ext.create ('Ext.ux.Deferred');
    dfd.resolve('foobar');
    return dfd.promise();
}

virtuallight avatar Oct 20 '14 11:10 virtuallight