This question is in regards to the V8 C++ API.
I would like to keep a global reference to a javascript function from a context
That is instead of storing the function in a local handle
Local<Function> init = ...
I would like to store it in a persistent handle
Persistent<Function> init = ...
I think the proper way to do so is like so:
Local<Function> l_init = ...
Persistent<Function> init = currentScope.Close(l_init);
but currentScope.Close() returns a local handle.
Is it possible for me to cache a handle as a class member so i don’t have to do a Get every frame?
Can i just have Local as a class variable, assign it using currentScope.Close and release it when i’m done with the Dispose function?
If you would like to store it in a Persistent handle you really don’t need to worry about scope. For the purpose of this discussion the major thing the closing of a scope will do is potentially mark your object for garbage collection.
In your example I think you want to do the following: