-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Can't read from a file using JSPromise #121
Comments
The problem is here: let promise = file.text.function!.callAsFunction().object! The use of let promise = file.text().object! |
Indeed, though I actually had to change it to: let promise = file.text!().object! But now I'm getting:
|
I fixed it by changing it to: let jsPromise = JSPromise<JSValue, Error>(promise)!
jsPromise.then { value in
let console = JSObject.global.console.object!
let log = console.log.function!
log(value)
// Without this, `jsPromise` gets released before this
// closure gets called.
print(jsPromise)
} but I feel like it's not the best solution. |
I think that’s the best we can do for now. There isn’t currently a cross-browser supported way for us to keep an object alive on the Swift side as long as its corresponding JS object remains alive. So you have to keep a strong reference to the |
I know that this is more of a support issue than a bug report, but I really don't know what else to try, and didn't find another help channel.
Here is the entire script using Tokamak:
which is throwing this error:
Running
works though.
The text was updated successfully, but these errors were encountered: