I am confused by the syntax of Kotlin's lambda.
I have first
.subscribe( { println(it) } , { println(it.message) } , { println("completed") } )
which works great .
Then I moved onNext to another class called GroupRecyclerViewAdapter, which implements Action1<ArrayList<Group>> .
.subscribe( view.adapter as GroupRecyclerViewAdapter , { println(it.message) } , { println("completed") } )
However, I got the error:

Error:(42, 17) Type mismatch: inferred type is () -> ??? but rx.functions.Action1<kotlin.Throwable!>! was expected Error:(42, 27) Unresolved reference: it Error:(43, 17) Type mismatch: inferred type is () -> kotlin.Unit but rx.functions.Action0! was expected
I can fix the error by changing it to:
.subscribe( view.adapter as GroupRecyclerViewAdapter , Action1<kotlin.Throwable> { println(it.message) } , Action0 { println("completed") } )
Is there a way to write lambda without specifying a type? ( Action1<kotlin.Throwable> , Action0 )
Note: Subscription is an RxJava Method
Change 1
class GroupRecyclerViewAdapter(private val groups: MutableList<Group>, private val listener: OnListFragmentInteractionListener?) : RecyclerView.Adapter<GroupRecyclerViewAdapter.ViewHolder>(), Action1<ArrayList<Group>> {
kotlin rx-kotlin
pt2121
source share