pardom
02/21/2023, 8:40 PMdoThing()
◦ doThingAsync()
◦ doThingSuspending()
◦ doThingSuspended()
◦ etc?ephemient
02/21/2023, 8:43 PMfun doThingBlocking()
◦ suspend fun doThing()
if both need to exist, otherwise only the latterpardom
02/21/2023, 8:45 PMfold
function where the closure invokes a suspending function, like so:
fun parse(input: String): Result<Parsed, Error>
parse(inputString).fold(
{ value -> suspendingNetworkCall(value) },
{ error -> suspendingLoggingCall(error) }
)
fold
and foldSuspended
at the moment. 😬ephemient
02/21/2023, 8:46 PMinline
, and then it works the same regardless of whether the lambdas suspend or notpardom
02/21/2023, 8:47 PMcrossinline
for the HOFsephemient
02/21/2023, 8:49 PMfun Result<Parsed, Error>.fold(
onSuccess: (Parsed) -> R,
onError: (Error) -> R,
)
suspend fun Result<Parsed, Error>.fold(
onSuccess: suspend (Parsed) -> R,
onError: suspend (Error) -> R,
)
pardom
02/21/2023, 8:51 PMcrossinline
fixed my issue. Thanks.