Answer the question
In order to leave comments, you need to log in
Generic class, array of types, how to call array processing by type method?
There is an interface
interface IEvents{
fun onDeviceChange(index: Int)
fun onDeviceAdd(index: Int)
}
class Obsr<T>() {
var list: Collection<T> = mutableListOf()
fun callAll(){
for (itm in list){
itm{метод который я вызываю через класс}
}
}
}
var events:Obsr<IEvents> = Obsr()
//Наполняем массив
//....
events.onDeviceChange(1) // вызывается функция callAll и проходится по массиву методом onDeviceChange
//...
events.onDeviceAdd(1) // вызывается функция callAll и проходится по массиву методом onDeviceAdd
Answer the question
In order to leave comments, you need to log in
No way. You can, of course, not this crappy design.
Write a normal event bus with annotations and you will be happy.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question