The use of jdeferred library

class=”htmledit_views”> How to use and test apply plugin: ‘java-library’ dependencies { implementation fileTree(dir: ‘libs’, include: [‘*.jar’]) compile ‘org.jdeferred.v2:jdeferred-core:2.0.0-beta2’ compile ‘org.slf4j:slf4j-simple:1.7.7’ // compile ‘org.jdeferred:jdeferred-android-aar:1.2.4’ } //org.slf4j // slf4j-simple //1.7.7 sourceCompatibility = “1.8” targetCompatibility = “1.8” Key method when() Executed in sub-threads Multiple callbacks can be added. fail()Failed callback done()Successful callback always() Both success and failure will call back progress() The interceptor of the callback filter() triggered by calling notify is executed in the main thread, which can forcefully change a result. resolve stands for resolution and hooks up with the done() callback reject stands for rejection and hooks up with the fail callback Notes If there is an error in multiple when, it will directly call fail and will not trigger done Common categories Deferred deferred = new DeferredObject(); This kind of object needs to manually call resolve or reject Example Promise promise = deferred. promise(); promise. done(new DoneCallback() { @Override public void onDone(Object result) { System.out.println(“done ” + result + ” ” + Thread.currentThread().getName()); } }).fail(new FailCallback() { @Override public void onFail(Object result) { System.out.println(“fail ” + result + ” ” + Thread.currentThread().getName()); } }).progress(new ProgressCallback() { @Override public void onProgress(Object progress) { System.out.println(“progress ” + progress + ” “…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索