vendredi 4 décembre 2020

Kotlin reflection with coroutines

I need to call the method suspend fun insert(e: T) by reflection declared as follows:

interface IMutableDao<T> {

    @Insert(onConflict = OnConflictStrategy.ABORT)
    suspend fun insert(e: T)

    @Update
    suspend fun update(e: T)

    @Delete
    suspend fun delete(e: T)
}

I tried with:

val insertFun = IMutableDao::class.functions.find {
            it.name.equals("insert", true)
        }
insertFun!!.callSuspend(dao, o)

But I get the exception "Callable expects 3 arguments, but 2 were provided.". I do not understand where the 3rd argument comes from.





Aucun commentaire:

Enregistrer un commentaire