Whats the equivalent coroutine code in 1.3 for thi...
# coroutines
p
Whats the equivalent coroutine code in 1.3 for this code..
Copy code
return async {
            val newConsent = consent.copy(createdAt = getConsent()?.createdAt)
            val uniqueId = getUniqueId().await()

            val consentFromApi = userServiceApi.consentApiClient.putConsent(uniqueId, newConsent).await()

            localStorageService.setConsent(consentFromApi)
        }
Which should return a Deferred<Unit>
g
This also should work on 1.3 (are you talking about coroutines or Kotlin? Anyway, should work on both)
Also, why do you need Deferred<Unit> instead of just Job? Or you want to cache result?
p
I’m updating some old legacy code and just making it work with 1.3 for now, but ill check out Job if you think that’s more suitable
g
Depends on case, but usually if you don't want to get result you should use
launch
instead of
async
p
Thanks
g
And general approach in coroutines is to use suspend function that returns result (even if this result is Unit) instead of returning Deffered/Job
☝️ 2
d
GlobalScope.async