Reputation: 1361
I am using RxBinding for Android widgets. I would like to do the following: Observable<java.lang.Void> obs = RxView.clicks(button);
But I get a compile time error saying that the expected type is kotlin.Unit
. RxView.clicks(button)
returns an Observable<Unit>
but I don't think that Java has a Unit datatype.
How do I get an Observable<Void>
in Java?
Upvotes: 0
Views: 1781
Reputation: 13515
You can live with Observable<Unit>
in Java. kotlin.Unit
is a class file available for java programs as soon as kotlin-stdlib-<some version>.jar
is in your class path, and it is there already because it is required by RxBinding.
If, however, some other part of your program requires Observable<Void>
, it can be obtained with:
Observable<Unit> ou = RxView.clicks(button);
Observable<Void> ov = ou.as(unit->null);
Upvotes: 1