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

[Question] Is there a way to reference the object in the callback? #69

Open
Yaojian opened this issue Jan 19, 2016 · 2 comments
Open

[Question] Is there a way to reference the object in the callback? #69

Yaojian opened this issue Jan 19, 2016 · 2 comments

Comments

@Yaojian
Copy link

Yaojian commented Jan 19, 2016

I tried to execute a function which belongs to the weak referenced object inside the callback, for example, obj.dispose(). Is it possible?

The callback passed in weak(Object obj [, Function callback]) does not receive any argument when it is invoked, while referencing the obj inside the callback directly will prevent the callback being invoked as the obj still has active reference and cannot be GCed.

@acarstoiu
Copy link

Yes, there is, see the README.md file. What you're looking for is the weak.get(ref) function.

@mvduin
Copy link

mvduin commented Jun 28, 2017

Calling weak.get(ref) inside the callback results in a segfault.

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

3 participants