Sergey Zabelnikov Sergey Zabelnikov - 1 month ago 17
Android Question

RxJava2 could not find Func0

RxJava 2 almost released and i won't to migrate from RX 1.2.0 to 2.0.0, But I have noticed that there is no Func0 interface in RxJava 2.

What developers should use instead of Func0 in RxJava 2?

Answer

From their elaboration on what's changed between RxJava 1.x and 2.x:

We followed the naming convention of Java 8 by defining io.reactivex.functions.Function and io.reactivex.functions.BiFunction, plus renaming Func3 - Func9 into Function3 - Function9 respectively. The FuncN is replaced by the Function<Object[], R> type declaration.

In addition, operators requiring a predicate no longer use Func1<T, Boolean> but have a separate, primitive-returning type of Predicate<T> (allows better inlining due to no autoboxing).

The io.reactivex.functions.Functions utility class offers common function sources and conversions to Function<Object[], R>.

Comments