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

请问有没有异步api的开发计划 #855

Closed
fengjx opened this issue Nov 22, 2018 · 7 comments
Closed

请问有没有异步api的开发计划 #855

fengjx opened this issue Nov 22, 2018 · 7 comments

Comments

@fengjx
Copy link

fengjx commented Nov 22, 2018

现在全部api都是同步的,在很多异步web框架(vertx、ktor等)中使用会阻塞主线程,有考虑这方面的支持吗

@binarywang
Copy link
Owner

不知道你说的支持是什么样的?能否给个例子?

@fengjx
Copy link
Author

fengjx commented Nov 22, 2018

就是例如WxMpXXXService的方法没有返回值,把返回结果放到回调接口里面。
其实就是RequestExecutor接口需要多实现一个方法,然后WxMpXXXService的方法再增加相应重载方法,可以同步返回结果,也可以在回调接口中处理返回结果

public interface RequestExecutor<T, E> {
  T execute(String uri, E data) throws WxErrorException, IOException;
  void execute(String uri, E data, ResponseCallback<T> callback) IOException;
}

@binarywang
Copy link
Owner

如果可以的话,提交PR代码如何?毕竟目前只有你在考虑使用此种方式,还可以顺便测试下。

@fengjx
Copy link
Author

fengjx commented Nov 25, 2018

好,我抽时间梳理下源码

@binarywang
Copy link
Owner

期待

@binarywang
Copy link
Owner

看来楼主一直没时间,我顺便帮忙实现了下,不知道是否满足需求,欢迎试用

@binarywang
Copy link
Owner

3.2.8.B测试版本已增加,欢迎试用

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