I have a lambda function that doesn't require any parameter:
Observable.interval(5, TimeUnit.SECONDS)
.subscribe(x -> new CryptoCompareRxService().getHistoricalDaily("BTC", "USD")
.subscribe(historicalDaily -> System.out.println("historicalDaily = " + historicalDaily)));
I would like to replace the "x
" by "()
" because it is useless:
Observable.interval(5, TimeUnit.SECONDS)
.subscribe(() -> new CryptoCompareRxService().getHistoricalDaily("BTC", "USD")
.subscribe(historicalDaily -> System.out.println("historicalDaily = " + historicalDaily)));
But when I do that, I get an error:
Cannot infer functional interface type
Why?
Here is the full class:
package com.tests.retrofitrxjava;
import com.tests.retrofitrxjava.rx.CryptoCompareRxService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import rx.Observable;
import java.util.concurrent.TimeUnit;
@SpringBootApplication
public class RetrofitRxjavaApplication {
public static void main(String[] args) {
SpringApplication.run(RetrofitRxjavaApplication.class, args);
Observable.interval(5, TimeUnit.SECONDS)
.subscribe(x -> new CryptoCompareRxService().getHistoricalDaily("BTC", "USD")
.subscribe(historicalDaily -> System.out.println("historicalDaily = " + historicalDaily)));
}
}