-
Hello, I recently just found out about this project and first of all I'd just like to say thanks for all the great work you've done and also for providing a more up to date version of J2V8, that was really useful :) I have an existent application that relies on J2V8 and I was thinking about migrating to Javet because it seems to be a much better alternative and actively maintained aswell. But I'm not sure Javet supports all the features I need so I want to ask first before I put in the effort of migrating the application. Some of the features I already noticed are present but I'm not sure about some of them. Here's the features my application is currently using with J2V8:
public void doThing(MyCustomObject obj) {
v8Context.executeJSFunction("doThing", obj); //being able to pass MyCustomObject to the javascript context
}
Can you confirm if all those 3 features are possible with Javet at the moment? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Thank you for asking these questions. Indeed, you are not alone because I faced these questions before creating Javet. Short answer is yes, all these 3 features are supported. I created a few tutorials that cover all of them. I suggest you spend some time evaluating the tutorials and sample code. I migrated my personal projects to Javet from v0.7.0. The migration was a little bit painful, but very exciting and there was no outstanding issues. It just worked as expected. Good luck to you. Of course, if you face any issues, I will be very happy to help investigate or fix them. |
Beta Was this translation helpful? Give feedback.
-
@caoccao I looked into the documentation but I'm not being able to achieve 1. and 3. Maybe I'm not doing it right, here's my code I wrote to test it: //create custom object
TestObject test = new TestObject();
test.setName("abc");
test.setType("test");
//convert it to a V8Value
JavetObjectConverter converter = new JavetObjectConverter();
V8Runtime v8 = V8Host.getNodeInstance().createV8Runtime();
V8Value val = converter.toV8Value(v8, test);
//load the script
V8Runtime script = v8.getExecutor(new File("C:\\main.js")).getV8Runtime();
//call javascript function: helloFunc(value) and pass the test object
script.invoke(script.getGlobalObject(), "helloFunc", false, val); My main.js: function helloFunc(testValue){
console.log(testValue.getName());
} I tried it with a node instance and a normal instance. The converter seems to convert my test object to V8Undefined, but even if I pass a string instead of my custom object, the javascript function is never triggered. |
Beta Was this translation helpful? Give feedback.
Thank you for asking these questions.
Indeed, you are not alone because I faced these questions before creating Javet. Short answer is yes, all these 3 features are supported.
I created a few tutorials that cover all of them. I suggest you spend some time evaluating the tutorials and sample code.
I migrated my personal projects to Javet from v0.7.0. The migration was a little bit painful, but very exciting and there was no outstanding issues. It just worked as expected. Good luck to you. Of course, if you face any issues, I will be very happy to help investigate or fix them.