I was trying to understand what's going on in this code. I am sure it referred to Java 8's method reference but I didnt get the idea.
I need to understand the last line:
...
subscribe(result::setResult,result::setErrorResult);
What actually happens behind the scene? what subscribe actually gets and how would you implement it without lambad's (to understand this idea)
taken from here:
public DeferredResult<FlightDetails> getAllFlightDetails() { Observable<String>availableFlightBookings=flightBookingIntegrationService.getAvailableFlightBookings();
Observable<String> couponId=couponIntegrationService.getCoupon();
DeferredResult<FlightDetails> result = new DeferredResult();
Observable.zip(availableFlightBookings,couponId, (avaliable, coupon) -> {
// do some logic here or just..
return new FlightDetails(avaliable,coupon);
}).subscribe(result::setResult,result::setErrorResult);
return result;
}
subscribe signature:
public final Subscription subscribe(final Action1<? super T> onNext, final Action1<Throwable> onError)
Thank you, ray.