Package com.google.gwt.query.client.plugins.deferred

Examples of com.google.gwt.query.client.plugins.deferred.PromiseFunction


  public Promise getXhr(final Settings settings) {
    return getXhr(settings, true);
  }

  private Promise getXhr(final Settings settings, final boolean cors) {
    return new PromiseFunction() {
      public void f(Deferred dfd) {
        try {
          Response response = httpClient(settings, cors);
          int status = response.getStatusCode();
          if (status <= 0 || status >= 400) {
View Full Code Here


  }
 
  int progress = 0;
  public void testPromiseFunction() {
    delayTestFinish(3000);
    final Promise doSomething = new PromiseFunction() {
      @Override
      public void f(final Deferred dfd) {
        new Timer() {
          int count = 0;
          public void run() {
            dfd.notify(count ++);
            if (count > 3) {
              cancel();
              dfd.resolve("done");
            }
          }
        }.scheduleRepeating(50);
      }
    };
   
    doSomething.progress(new Function() {
      public void f() {
        progress = this.<Integer>getArgument(0);
      }
    }).done(new Function() {
      public void f() {
        assertEquals(3, progress);
        assertEquals(Promise.RESOLVED, doSomething.state());
        finishTest();
      }
    });
  }
View Full Code Here

 
  public void testNestedPromiseFunction() {
    progress = 0;
    delayTestFinish(3000);
   
    Promise doingFoo = new PromiseFunction() {
      public void f(final Deferred dfd) {
        new Timer() {
          int count = 0;
          public void run() {
            dfd.notify(count ++);
            if (count > 3) {
              cancel();
              dfd.resolve("done");
            }
          }
        }.scheduleRepeating(50);
      }
    };
   
    Promise doingBar = new PromiseFunction() {
      public void f(final Deferred dfd) {
        new Timer() {
          int count = 0;
          public void run() {
            dfd.notify(count ++);
View Full Code Here

    return new PromiseReqBuilderJSONP(settings.getUrl(), settings.getTimeout());
  }
 
  @Override
  public Promise getLoadScript(final Settings settings) {
    return new PromiseFunction() {
      private ScriptElement scriptElement;
      public void f(final Deferred dfd) {
        scriptElement = ScriptInjector.fromUrl(settings.getUrl()).setWindow(GQuery.window)
        .setCallback(new Callback<Void, Exception>() {
          public void onSuccess(Void result) {
View Full Code Here

    callbacks2.fire("foo");
    assertEquals(" f1: foo f2: foo", result);
  }
 
  public void testThen() {
    new PromiseFunction() {
      public void f(final Deferred dfd) {
        dfd.resolve(5d);
      }
    }.done(new Function() {
      public void f() {
View Full Code Here

 
  public void testDone() {
    done = false;
    delayTestFinish(5000);
   
    when(new PromiseFunction() {public void f(Deferred dfd) {
      dfd.resolve("Hi");
    }}).done(new Function(){public void f() {
      assertEquals("Hi", arguments(0));
      finishTest();
      done = true;
View Full Code Here

  public void testDeferredThenDone() {
    done = false;
    delayTestFinish(5000);

    GQuery
      .when(new PromiseFunction() {
        public void f(Deferred dfd) {
          dfd.resolve("message");
        }
      })
      .and(new FunctionDeferred() {
View Full Code Here

  public void testDeferredThenFail() {
    done = false;
    delayTestFinish(5000);

    GQuery
      .when(new PromiseFunction() {
        public void f(Deferred dfd) {
          dfd.resolve("message");
        }
      })
      .and(new Function(){
View Full Code Here

  public void testDeferredOr() {
    done = false;
    delayTestFinish(5000);

    GQuery
      .when(new PromiseFunction() {
        public void f(Deferred dfd) {
          dfd.reject("reject-when");
        }
      })
      .or(new FunctionDeferred() {
View Full Code Here

  }


  public void testProtected() {
    delayTestFinish(20);
    GQuery.when(new PromiseFunction() {
      public void f(final Deferred dfd) {
        GQuery.when(new Function() {
          public void f() {
            // This causes an '...IllegalAccessError: tried to access class ...Deferred$DeferredPromiseImpl ...'
            // in dev-mode when resolve is protected. It works in JRE and production though.
View Full Code Here

TOP

Related Classes of com.google.gwt.query.client.plugins.deferred.PromiseFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.