我正在使用RxJava 2
& Retrofit 2
(https://github.com/JakeWharton/retrofit2-rxjava2-adapter),我想知道如何处理无响应(204)类型。在 rxjava1 我正在使用Observable<Void>
但 rxjava2 不再允许它(https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0 -> Nulls)
现在,我已经绕过自定义类型(我称之为 NoContent)的 Json 解析,但我想知道是否有更好的方法。
编辑:
public class NoContent {
public static class GsonTypeAdapter extends TypeAdapter<NoContent> {
@Override
public void write(JsonWriter out, NoContent value) throws IOException {
out.nullValue();
}
@Override
public NoContent read(JsonReader in) throws IOException {
return new NoContent();
}
}
}