Skip to content

Add support for async / await #84

Description

@amirouche

In modern javascript, there is async and await new keywords that allows to write asynchronous code that looks like synchronous code. For instance,

async function fetchPosts() {
    let response = await fetch('/api/posts');
    if (response.status === 200) {
         let posts = await response.json();
         return posts;
    }
}

Is it possible to have support for that? I don't how to port my framework to racketscript without this (see. #61).

The above should be possible to be written in racketscript using a syntax that looks like the following:

(define-async (fetch-posts
 (let ((response (await (fetch "/api/posts"))))
       (if (= (response-status response) 200)
           (await (response-json response)))))

It should also be possible to define async lambda.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions