lively4-core icon indicating copy to clipboard operation
lively4-core copied to clipboard

Allow await on top level in Workspace

Open onsetsu opened this issue 7 years ago • 1 comments

Currently, we cannot use await to wait for Promises in Workspaces (e.g. when fetching a resource).

To fix this: Update source code transformation to allow for top-level await statements.

When alternating the source code transformation, we have to consider the following:

  • Arrange the order to move imports to the top of the file.
  • Enclose all other statements in an asyncronous iife.
    • the function should return a do-expression over all moved statements to provide the last evaluated statement as result
  • take care of top-level variables, that still need to be recorded

onsetsu avatar May 03 '17 15:05 onsetsu

BUMP BUMP BUMP @onsetsu BUMP BUMP BUMP I want this feature, I have to type the following code over and over and over

var value;
(async () => {
  value = await somthin()
})()

JensLincke avatar Sep 11 '19 10:09 JensLincke