https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
p

pandawarrior

04/01/2019, 10:12 AM
I have caught
kotlin.TypeCastException
while using coroutine’s
async/await
in
common
when running on iOS. But it works well on Android. Any advice to go about this?
s

svyatoslav.scherbina

04/01/2019, 10:19 AM
p

pandawarrior

04/02/2019, 3:04 AM
Thanks, I saw the closed issue about using
delay
caused
TypeCastException
but it is actually
IllegalStateException
because the dispatcher doesn’t implement the Delay interface. So we will have to implement the Deferred<Unit> (Generic is not available K/N) in to a custom dispatcher class? Are there any examples to go about it?
s

svyatoslav.scherbina

04/02/2019, 6:09 AM
Thanks, I saw the closed issue about using
delay
caused
TypeCastException
but it is actually
IllegalStateException
because the dispatcher doesn’t implement the Delay interface.
Could you clarify, do you encounter
TypeCastException
or
IllegalStateException
?
So we will have to implement the Deferred<Unit> (Generic is not available K/N) in to a custom dispatcher class?
How is
Deferred
related?
p

pandawarrior

04/02/2019, 6:31 AM
>> Could you clarify, do you encounter
TypeCastException
or
IllegalStateException
?
I encountered
kotlin.TypeCastException
when using
async/await
in
commonMain
>> How is
Deferred
related?
https://github.com/Kotlin/kotlinx.coroutines/issues/470, The temporary solution to solving
TypeCastException
for using
delay
is to implement
Delay
to the class subclassing
CoroutineDispatcher()
. So if I am not mistaken, the problem to
TypeCastException
to using
async/await
is the implementation of the
Deferred
interface in class that subclass
CoroutineDispatcher()
.
s

svyatoslav.scherbina

04/02/2019, 6:49 AM
Do you mean
Deferred
or
Delay
?
Are there any examples to go about it?
I believe there is one in the comments to the issue.