0
public class ReactiveExample {
public static void main(String[] args) throws InterruptedException, NumberFormatException, UnsupportedEncodingException {
Observable.range(1, 5).subscribe(
System.out::println,
error -> System.out.println("error"),
() -> System.out.println("completed")
);
}
}
即打印出來的結果是[email protected]
ReactiveX Java過程早期完成?
後可觀察到的打印我得到:
Process finished with exit code 0
。
我剛剛開始使用ReactiveX,並且一直在關注一些教程。我的假設是,上面的代碼將連續傳輸數據,如下所示:
1-2-3-4-5-1-2-3-4-5...
並繼續打印該值。爲什麼我的程序會立即停止?它是否在觀察到前5位數後才結束?我怎樣才能改變這個值來持續流化數值並在這些數值循環時打印出來?另外,我如何實際打印值而不是可觀察對象引用?
因爲範圍完成時到達範圍的結束 – EpicPandaForce