Quantcast
Channel: Javascript .NET
Viewing all articles
Browse latest Browse all 137

Commented Issue: v8 function wrapper. [11682]

$
0
0
Hi.
While working with the library I've noticed that there is no support for js callbacks in .NET code. Function objects supplied to .net code (e.g. as method arguments) are converted to empty dictionaries which obviously are not very useful.
So I've created my own wrapper for functions and would like to share with others. May be someone will find it useful too.
Attached are 2 files (.cpp/.h) that describe managed class JavascriptFunction. It holds v8 handle to js function which can be called from .NET code. To use this new class small patch to JavascriptInterop class should be applied (also attached).
Comments: ** Comment from web user: Ariman **

One more thing. Further testing of the code revealed that finalizer requires JavascriptScope usage inside. Or Dispose fails with message about isolate is null. Fixed method (at least this version worked for me)
```
JavascriptFunction::!JavascriptFunction()
{
JavascriptScope scope(mContext);

mFuncHandle->Dispose();
delete mFuncHandle;
}
```


Viewing all articles
Browse latest Browse all 137

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>