https://kotlinlang.org logo
#coroutines
Title
# coroutines
s

Seri

03/06/2019, 7:01 PM
I’m seeing some odd behavior with
CompletableDeferred
. I’m using it to wrap an Android UI prompt, so I’m setting a
lateinit var CompletableDeferred
before launching the prompt, then completing it from the system callback once the user action is complete. However, the var is always
null
when I try to complete it. Is there an obvious flaw here, or a better approach?
Figured it out!
I was accidentally creating two instances of the class containing the Deferred variable. The first one was kicking off the UI action and waiting for a response, and the second one was swallowing the UI response and wasn’t properly initialized
b

bdawg.io

03/06/2019, 8:48 PM
Yeah, an object is still an object as far as
lateinit var
is concerned.
10 Views