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

Track JavaScript data lifetimes #78

Open
semirix opened this issue Sep 13, 2020 · 2 comments
Open

Track JavaScript data lifetimes #78

semirix opened this issue Sep 13, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@semirix
Copy link

semirix commented Sep 13, 2020

I'm embedding this in a rendering application where rendered objects can be scripted in the frontend. The problem is that the rendered objects are managed in Rust but created in JavaScript. When the JS objects are garbage collected, they remain in the Rust backend. Ideally this should be automated so when the JS objects are deleted there is some automated way of having the Rust data associated be deleted too. Is there a way of achieving this currently or a implementation that could enable this?

@chayleaf
Copy link
Contributor

chayleaf commented Nov 2, 2020

@theduke theduke added the enhancement New feature or request label Feb 4, 2021
@theduke
Copy link
Owner

theduke commented Feb 4, 2021

As @pavlukivan pointed out, this is possible.

It would require exposing the JS_NewClass, SetOpaque and then provide a finalizer that can call a Rust callback.

Currently the exposed QuickJS API surface is very minimal on purpose.

I probably won't have time to implement this anytime soon, but I'd happily accept a PR.

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

No branches or pull requests

3 participants