settle(type, oldArgs);
}
}
-
+
private void settle(int action, Object... args) {
if (action == DONE) dfd.resolve(args);
if (action == FAIL) dfd.reject(args);
- if (action == PROGRESS) dfd.notify(args);
+ if (action == PROGRESS) dfd.notify(args);
}
}
-
+
protected com.google.gwt.query.client.plugins.deferred.Deferred dfd;
/**
public Promise always(Function... f) {
return done(f).fail(f);
}
-
+
public Promise and(Function f) {
return then(f);
}
-
+
public Promise done(Function... f) {
dfd.resolve.add(f);
return this;
dfd.reject.add(f);
return this;
}
-
+
public Promise or(final Function f) {
return then(true, null, f);
- }
-
+ }
+
public Promise pipe(Function... f) {
return then(f);
}
progress(new ThenFunction(newDfd, f, PROGRESS, continueFlow));
return newDfd.promise();
}
-
+
public Promise then(final Function... f) {
return then(false, f);
}
}
return when(p);
}
-
+
private static Promise makePromise(final Object o) {
if (o instanceof Promise) {
return (Promise)o;
};
}
}
-
+
public static Promise when(Promise... d) {
final int n = d.length;
switch (n) {
* Call the progressCallbacks on a Deferred object with the given args.
*/
public Deferred notify(Object... o) {
- notify.fire(o);
+ if (state == PENDING) notify.fire(o);
return this;
}
* Reject a Deferred object and call any failCallbacks with the given args.
*/
public Deferred reject(Object... o) {
- reject.fire(o);
+ if (state == PENDING) reject.fire(o);
return this;
}
* Resolve a Deferred object and call any doneCallbacks with the given args.
*/
public Deferred resolve(Object... o) {
- resolve.fire(o);
+ if (state == PENDING) resolve.fire(o);
return this;
}