I'm trying to learn Java Lamdas.
I'm trying to convert the following code into lambda representation but it's not working:
private void foo(Data data) {
Observable.just(data).subscribeWith(new DisposableObserver<Data>() {
int count = 0;
int pageCount = 0;
@Override
public void onNext(Data data) {
Timber.e("onNext()");
count = data.getCount();
pageCount = data.getPage();
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
@Override
public void onComplete() {
Log.e("class", "onComplete");
abc(count, pageCount);
}
});
}
private void bar(Data data) {
Observable.just(data).subscribeWith({
int count = 0;
int pageCount = 0;
data -> {
Timber.e("onNext()");
count = data.getCount();
pageCount = data.getPage();
},
e -> e.printStackTrace(),
() -> {
Log.e("class", "onComplete");
abc(count, pageCount);
}
});
}
This is giving me error. I'm not really sure how to fix it.