I'm trying to port an RxJava library and leverage extension functions in Kotlin.
fun <T,R: MutableCollection<T>> Observable<T>.collectWhile(factory: (() -> R), condition: (R,T) -> Boolean) =
compose(Transformers.collectWhile(factory,condition))
The Transformers.collectWhile()
is written in Java and has this signature:
public static <T, R extends Collection<T>> Transformer<T, R> collectWhile(final Func0<R> factory,
final Action2<? super R, ? super T> collect)
However, I am getting an issue with mapping the collect
argument and I'm not good at generics. How do I express super
with a functional type?
UPDATE
Stupid mistake on my part. I should not have been posting on SO late at night.
I was actually targeting this
public static <T, R extends Iterable<?>> Transformer<T, R> collectWhile(final Func0<R> factory,
final Action2<? super R, ? super T> collect, final Func2<? super R, ? super T, Boolean> condition)
And this is what I should have done.
fun <T,R: MutableCollection<T>> Observable<T>.collectWhile(factory: (() -> R), action: (R,T) -> Unit, condition: (R,T) -> Boolean) =
compose(Transformers.collectWhile(factory,action,condition))