Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jquery promise issues inherited? #341

Open
ksrb opened this issue Feb 2, 2015 · 0 comments
Open

Jquery promise issues inherited? #341

ksrb opened this issue Feb 2, 2015 · 0 comments
Assignees

Comments

@ksrb
Copy link

ksrb commented Feb 2, 2015

I think this is a pretty well know problem with JQuery but I didn't see any open issues when I searched "promises", so apologies if you guys are already aware of this issue.

The below are samples from a working gist.

Problem 1: Error handling
Errors are not being passed to next then(), or even bubbling up to the application at all, did I use the api wrong?

    private void errorHandling() {
        final Promise promise = timeOut(1000);
        promise.then(new Function() {
            public void f() {
                throw new Error("I want to fail");
            }
        }, new Function() {
            public void f() {
                log.info("Not here? Nope");
            }
        }).fail(new Function() {
            public void f() {
                log.info("How about here? Nope");
            }
        });
    }

In the above the error seems to just disappear...

Problem 2: Execution order

    private void executionOrder() {
        log.info("This");
        final Promise promise = timeOut(1000);
        promise.then(new Function() {
            public void f() {
                log.info("expected from an async api");
            }
        });
        log.info("is");
        Timer timer = new Timer() {

            @Override
            public void run() {
                log.info("He");
                promise.then(new Function() {
                    public void f() {
                        log.info("BAD THINGS");
                    }
                });
                log.info("comes");
            }

        };
        timer.schedule(2000);
    }

The expected console output should be:

This is expected from an async api
He comes BAD THINGS

But the actual is:

This is expected from an async api
He BAD THINGS comes

Additional Information
GWT: 2.7
GWTQuery: 1.4.4 - snapshot (1/30/2015)

@manolo manolo self-assigned this Feb 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants