2017-10-16 13 views
1

Voici une tentative stub échoué à Flowable.generate (avec plus d'annotations de type que j'utilise normalement):Comment utilisez-vous Flowable.generate de Kotlin

val xs: Flowable<String> = Flowable.generate<Int, String>(
    java.util.concurrent.Callable<Int> { -> 0 }, 
    io.reactivex.functions.BiConsumer<Int, String> { t1, t2 -> } 
) 

La signature Java Je voudrais utiliser est:

public static <T, S> Flowable<T> generate(Callable<S> initialState, final BiConsumer<S, Emitter<T>> generator) 

L'erreur que je reçois est:

Error:(145, 12) None of the following functions can be called with the arguments supplied: 
@CheckReturnValue @BackpressureSupport @SchedulerSupport public final fun <T : Any!, S : Any!> generate(p0: (() -> (???..???))!, p1: (((???..???), Emitter<(???..???)>!) -> Unit)!): Flowable<(???..???)>! defined in io.reactivex.Flowable 
@CheckReturnValue @BackpressureSupport @SchedulerSupport public final fun <T : Any!, S : Any!> generate(p0: (() -> (???..???))!, p1: ((???, Emitter<(???..???)>) -> ???)!): Flowable<(???..???)>! defined in io.reactivex.Flowable 
@CheckReturnValue @BackpressureSupport @SchedulerSupport public open fun <T : Any!, S : Any!> generate(p0: Callable<(???..???)>!, p1: BiConsumer<(???..???), Emitter<String!>!>!): Flowable<String!>! defined in io.reactivex.Flowable 
@CheckReturnValue @BackpressureSupport @SchedulerSupport public open fun <T : Any!, S : Any!> generate(p0: Callable<Int!>!, p1: BiFunction<Int!, Emitter<(???..???)>!, Int!>!): Flowable<(???..???)>! defined in io.reactivex.Flowable 

Qu'est-ce devrait Je nourris le compilateur?

Répondre

2

Le type de generate() doit être <String, Int> et le type BiConsumer doit être <Int, Emitter<String>>.

val xs: Flowable<String> = Flowable.generate<String, Int>(
     java.util.concurrent.Callable<Int> { -> 0 }, 
     io.reactivex.functions.BiConsumer<Int, Emitter<String>> { t1, t2 -> } 
) 
+0

J'aurais juré que j'ai triplé l'ordre des paramètres de type, mais évidemment pas. –