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

Alternative to creating references to non-objects #149

Closed
mika-fischer opened this issue Sep 29, 2017 · 6 comments
Closed

Alternative to creating references to non-objects #149

mika-fischer opened this issue Sep 29, 2017 · 6 comments

Comments

@mika-fischer
Copy link

nodejs/node#15289 removed the possibility to create references to values that are not objects.

My use-case is the following. I want to store arguments given to my function persistently. Then some time later I want to call a callback function with those parameters. In the past I just used a vector<Reference<Value>>. Now I don't quite understand how I'm supposed to do it...

As an example, see this test: https://github.com/mika-fischer/napi-thread-safe-callback/blob/e03dda83fb1d2a63fb8332406e2436fc18a63fba/test/tests.cpp#L36-L51

@gabrielschulhof
Copy link
Contributor

gabrielschulhof commented Sep 29, 2017 via email

@mika-fischer
Copy link
Author

OK, fair enough, that's slightly inconcenient, but not too bad...

But just so I understand: There's now no way at all to just hold onto say a string literal across calls into C++?

@gabrielschulhof
Copy link
Contributor

gabrielschulhof commented Sep 29, 2017 via email

@mika-fischer
Copy link
Author

Sure, I meant keeping the JS string without converting to C++. That seems impossible now, right?

And while converting a string to C++ by itself is not that bad, in cases like this where you get passed a Value and you don't care what it is, you just want to hold on to it for later use, things are a lot more complicated than before if you don't want to use this boxing trick...

@gabrielschulhof
Copy link
Contributor

gabrielschulhof commented Sep 29, 2017 via email

@mika-fischer
Copy link
Author

Ah I see, that makes sense then. Thanks for the explanations!

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

2 participants