coroutinedispatcher
04/29/2021, 9:31 PMinvoke()
methods? For example:
class Whatever(val callbackNumber1: (SomeParameter) -> Unit, val callbackNumber2: () -> Unit)
So now when call that instance in another object, I would have something like this:
class AnotherObject : (SomeParameter) -> Unit , () -> Unit {
private val whatever = Whatever(this, this)
override fun invoke(){
}
override fun invoke(someParameter: SomeParameter){
}
}
Or should I just stick to plain interfaces in this case?nanodeath
04/29/2021, 9:34 PMZach Klippenstein (he/him) [MOD]
04/29/2021, 9:35 PMcoroutinedispatcher
04/29/2021, 9:36 PMtypealias
doesn’t solve the issue.
@Zach Klippenstein (he/him) [MOD] Yup. That’s the way to go, I am just asking if there is some way to define actual names without creating an interfaceephemient
04/29/2021, 9:39 PM(name: Type) -> Unit
but it's really just a hint, nothing morenanodeath
04/29/2021, 9:39 PMephemient
04/29/2021, 9:40 PMephemient
04/29/2021, 9:40 PM(Foo) -> Unit
and (Bar) -> Unit
at the same time due to erasurecoroutinedispatcher
04/29/2021, 11:21 PM@JVMName
for `typeAlias`es in the future, so that instead of having invoke
name, we can define the name we want. It might probably be a little tricky for the compiler though.coroutinedispatcher
04/29/2021, 11:21 PMephemient
04/30/2021, 2:12 AMclass TwoFunctions : (Foo) -> Unit, (Bar) -> Unit { /* even assuming this works somehow */ }
val twoFunctions = TwoFunctions()
val fooFunction: (Foo) -> Unit = twoFunctions
val barFunction: (Bar) -> Unit = twoFunctions
fooFunction
and barFunction
have the same kotlin.jvm.functions.Function1
erasure, so their fun invoke(T)
is the sametateisu
04/30/2021, 4:25 AMephemient
04/30/2021, 4:42 AMkotlin.jvm.functions.Function0
and kotlin.jvm.functions.Function1
. but in general this is problematic