Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSClosure.async doesn't work at all #224

Closed
MihaelIsaev opened this issue Apr 11, 2023 · 0 comments
Closed

JSClosure.async doesn't work at all #224

MihaelIsaev opened this issue Apr 11, 2023 · 0 comments

Comments

@MihaelIsaev
Copy link

Hi guys, I'm trying to use JSClosure.async but it never called, while JSClosure works well in the same place.
I added a lot of prints under the hood in every call related to JSClosure.async but none of them has been called.

import JavaScriptKit

@main
public struct CartonApp {
    public private(set) var text = "Hello, World!"

    public static func main() async {
        print(CartonApp().text)
        if let docObj = JSObject.global.document.object, let bodyObj = JSObject.global.document.jsValue.body.object {
            var button = JSObject.global.document.createElement.function?.callAsFunction(this: docObj, "button").jsValue
            button?.innerText = "Click me".jsValue
            JSObject.global.document.jsValue.body.appendChild.function?.callAsFunction(this: bodyObj, button)
            if let buttonObj = button?.object {
                button?.addEventListener.function?.callAsFunction(this: buttonObj, "click", JSClosure.async({ args in
                    print("clicked async") // never called
                    return .undefined
                }))
            }
        }
    }
}

Could you please tell me if there is a bug or I'm using it wrong? If I'm using it wrong could you please provide me with any working example that I could easily launch.

Thanks in advance.

@MaxDesiatov @mjburghard @PatrickPijnappel @valeriyvan @yonihemi swiftwasm/swift#5376

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant