-
-
Notifications
You must be signed in to change notification settings - Fork 55
Closed
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request
Description
What is the best way to handle calls to asynchronous code inside a JSClosure
, especially if one needs to return the result of such call from the JSClosure
? Consider the following example:
let closure = .object(JSClosure { (arguments: [JSValue]) in
guard let url = arguments.first?.string else {
return JSValue.undefined
}
return await fetch(url)
})
This results in the following error:
cannot pass function of type '([JSValue]) async -> JSValue' to parameter expecting synchronous function type
The reason is obvious, but is there a nice way to work around this?
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request