JDeferred 是一个 Java 的 Deferred/Promise 库,类似 jQuery 的 Deffered 对象。
示例代码:
Deferred deferred = new DeferredObject(); Promise promise = deferred.promise(); promise.done(new DoneCallback() { public void onDone(Object result) { ... } }).fail(new FailCallback() { public void onFail(Object rejection) { ... } }).progress(new ProgressCallback() { public void onProgress(Object progress) { ... } }).always(new AlwaysCallback() { public void onAlways(State state, Object result, Object rejection) { ... } });