We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
OkResponse<T>
对于有且仅有一个范型的解析器,可通过toXxx<OkResponse<T>>方法同时获取响应头和实体类等信息
toXxx<OkResponse<T>>
但对于没有泛型的解析器或者有多个泛型的解析器,就没办法通过这个方式去获取,如下:
//无泛型 @rxhttp.wrapper.annotation.Parser(name = "User") class UserParser() : Parser<User> { override fun onParse(response: Response): User { TODO("Not yet implemented") } }
//两个范型 @Parser(name = "DoubleType") public class DoubleTypeParser<F, S> extends TypeParser<Pair<F, S>> { protected DoubleTypeParser() { super(); } public DoubleTypeParser(Type fType, Type sType) { super(fType, sType); } @Override public Pair<F, S> onParse(@NotNull okhttp3.Response response) throws IOException { Type pairType = ParameterizedTypeImpl.getParameterized(Pair.class, types); Response<Pair<F, S>> data = Converter.convertTo(response, Response.class, pairType); Pair<F, S> t = data.getData(); //获取data字段 if (data.getCode() != 0 || t == null) {//code不等于0,说明数据不正确,抛出异常 throw new ParseException(String.valueOf(data.getCode()), data.getMsg(), response); } return t; } }
此时就会生成toXxxUser及toXxxDoubleType系列方法,无法获取OkResponse<User>、OkResponse<Pair<F, S>>对象
toXxxUser
toXxxDoubleType
OkResponse<User>
OkResponse<Pair<F, S>>
下载也一样,目前下载只返回String或Uri对象,如果想获取OkResponse<String>或OkResponse<Uri>对象,就做不到
OkResponse<String>
OkResponse<Uri>
The text was updated successfully, but these errors were encountered:
4ad9a11
使用toObservableOkResponse、toAwaitOkResponse、toFlowOkResponse替代toObservable<OkResponse<T>>、toAwait<OkResponse<T>>、toFlow<OkResponse<T>>方法,需要在toXxx方法后调用
toObservableOkResponse、toAwaitOkResponse、toFlowOkResponse
toObservable<OkResponse<T>>、toAwait<OkResponse<T>>、toFlow<OkResponse<T>>
Sorry, something went wrong.
No branches or pull requests
对于有且仅有一个范型的解析器,可通过
toXxx<OkResponse<T>>
方法同时获取响应头和实体类等信息但对于没有泛型的解析器或者有多个泛型的解析器,就没办法通过这个方式去获取,如下:
此时就会生成
toXxxUser
及toXxxDoubleType
系列方法,无法获取OkResponse<User>
、OkResponse<Pair<F, S>>
对象下载也一样,目前下载只返回String或Uri对象,如果想获取
OkResponse<String>
或OkResponse<Uri>
对象,就做不到The text was updated successfully, but these errors were encountered: