Skip to content

Update promises to be awaitable using async/await #216

@matronator

Description

@matronator

Promises are so ugly, especially when you have to chain multiple .Then() blocks. So I tried to await the promise instead, but it won't compile because they're not awaitable.

Now this might be just a misunderstanding of C# promises, coming from JavaScript ESNext, but isn't async/await basically the same thing as promises, but with much cleaner and nicer syntax?

As in, doesn't this code

RestClient.Get("/api/something")
.Then(response => {
    Debug.Log(response.Text);
});

do the exact same thing as this one?

var response = await RestClient.Get("/api/something");
Debug.Log(response.Text);

Or at least it would if the promise could be awaited. Which would be awesome!

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