How do you call member functions on existing JavaScript objects? #88517
-
Using https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/import-export-interop?view=aspnetcore-7.0, I am not sure how to call member functions on existing for (var [name,node] of context.program.sourceFiles){
console.log(name);
} I would like to do the above in C#. Here is a failed attempt var program = context.GetPropertyAsJSObject("program");
var sourceFiles = program.GetPropertyAsJSObject("sourceFiles");
// How do I call 'entries'?
// This does not work.
var entries = MapPrototype.entries(sourceFiles); Where I was trying to define public partial class MapPrototype {
[JSImport("entries")]
public static partial JSObject entries(JSObject self);
} cc @pavelsavara |
Beta Was this translation helpful? Give feedback.
Answered by
pavelsavara
Jul 7, 2023
Replies: 1 comment 3 replies
-
OOP in not supported in Net7. You need to create another method in JS, wrap it as |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not yet, maybe Net9 but that's open discussion. OOP over interop boundary is not good idea in my opinion. It leads to chatty interactions with lots of overhead, GC pressure and other problems. I advise to create higher level functionality methods and interop with that instead.