Replies: 1 comment
-
Another question regarding this interoperability between platforms: there is a way to share a module (from .NET) from an in-process host, giving access to the state from .NET side? As an example of what I would try to do: public class AppExtensionPoint
{
[JSExport("app")]
public SampleState Current { get => this; }
[JSExport("testMethod")]
public async Task TestMethod(Guid uuid)
{
Console.WriteLine($"Value: {uuid}");
// ...
}
} Then, in the JS-side: import { app } from "my-module"; // Or using the "dotnet.require" from "node-api-dotnet"
await app.testMethod("a119eb9b-5da6-49f1-be5c-41c8a17f5070"); The specifics regarding this scenario would be that the .NET process itself would run the script (it will not run in a Node process), like this: await _node.RunAsync(async () =>
{
await _node.ImportAsync("/path/to/script", esModule: true);
}); So (at least what I would expect is) the script could run from .NET process, importing the ".NET structured/generated code" from JS-side and sharing the .NET process state (what would allow scripting as an extension point for the application, which is what I'm trying to do). Hope I could explain the main idea. I could even try to do exactly what I'm proposing here, but... this is expected to work? Or there is something that I'm missing here? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
-
Hello, community!
Considering this code, that interop with a custom scripting (from user code, for instance):
Basically, I'm emitting an event from C# that is handled in JS side. But the
CustomEvent
class needs the parameter being passed as a more complex structure. I was wondering if there is a better way to do it from C# code. Maybe marshalling a native object directly? It would be possible somehow?Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions