RxJava with Java 8 Stream

Below is example to use JDK 8 stream with RxJava Observable. 1234567891011121314151617181920import java.util.Date; import java.util.concurrent.TimeUnit; import java.util.stream.Stream; import io.reactivex.Observable; import io.reactivex.functions.Consumer; public class DemoRxJava { public static void main(String[] args) throws InterruptedException { Stream<Date> dates = Stream.generate(Date::new); Consumer<Date> consumer = System.out::println; Observable<Date> observable = Observable.fromIterable(() -> { return dates.iterator(); }); System.out.println("Waiting………….."); TimeUnit.MINUTES.sleep(1); System.out.println("Start…………."); observable.subscribe(consumer); } […]

Continue Reading