我有这个定制的 SingleObserver 类:
public abstract class SubscribeWithView<T> implements SingleObserver<T>,Disposable {
private WeakReference<RootView> rootView;
/**
* <p style="color:blue;">set view from presenter</p>
*
* @param rootView
*{@link RootView}
*/
public SubscribeWithView(RootView rootView) {
this.rootView = new WeakReference<>(rootView);
}
...
}
所以我在 API 存储库接口类中使用以下代码:
@POST(ApiAddress.USER_LOGIN)
Single<Response<UserWithToken>> userLogin(@Body UserLogin_request userLogin_request);
我的问题是:如何更改此代码:
.subscribe(new SubscribeWithView<Response<UserWithToken>>(view) {
@Override
public void onSuccess(Response<UserWithToken> response) {
}
@Override
public void onError(Throwable e) {
super.onError(e);
}
像这样 lambda 吗?
apiRepository.userLogin(request)
.subscribe(new SubscribeWithView<Response<UserWithToken>>(view) {
response->{},e->{});
哆啦的时光机
相关分类