Skip to content

Add getCompletedOrNull to Deferred<T> #4630

@owochle

Description

@owochle

Use case
In addition to the experimental Deferred<T>::getCompleted and Deferred<T>::getCompletionExceptionOrNull, it would be very useful to have getCompletedOrNull as a way to reduce this snippet.

if (deferred.isCompleted) {
    deferred.getCompleted()
} else {
    null
}

This way, it would be trivial to get an awaitable value from synchronous code and cleaner than the above snippet, or catching the IllegalState thrown by getCompleted

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions