mkosm
05/09/2020, 6:59 PMCastReceiverContext
by calling cast.framework.CastReceiverContext.getInstance()
. In order to do that, I've done this:
external object cast {
var framework: Framework
}
external object Framework {
var CastReceiverContext: CastReceiverContextStatic
}
external open class CastReceiverContextStatic() {
fun getInstance(): CastReceiverContext
}
// access it using:
val context = cast.framework.CastReceiverContext.getInstance()
This works, but I feel like there is a better way to do this. Is there?Robert Jaros
05/09/2020, 9:34 PMexternal val cast: dynamic
val context: CastReceiverContext = cast.framework.CastReceiverContext.getInstance()
mkosm
05/09/2020, 9:57 PMexternal val cast: dynamic
val context = cast.framework.CastReceiverContext.getInstance() as CastReceiverContext
but I was getting ReferenceError: CastReceiverContext is not defined
. I didn't know that specifying the type while declaring a dynamic
variable is different than casting it.Robert Jaros
05/09/2020, 10:46 PMCastReceiverContext
type defined in your project, because it's not defined in your sampleRobert Jaros
05/09/2020, 10:47 PMRobert Jaros
05/09/2020, 10:48 PMRobert Jaros
05/09/2020, 10:50 PMdynamic
variable you get an unchecked cast warning in IDE, and there is no check at runtimemkosm
05/09/2020, 10:50 PMRobert Jaros
05/09/2020, 10:51 PMmkosm
05/09/2020, 10:51 PMCastReceiverContext
by the way