Update JSObjectReference to IJSObjectReference#20069
Conversation
| } | ||
| ``` | ||
|
|
||
| `IJSInProcessObjectReference` represents a reference to a JavaScript object whose functions can be invoked synchronously. |
There was a problem hiding this comment.
Can we also add a snippet about IJSUnmarshalledObjectReference
IJSUnmarshalledObjectReference represents a reference to an JavaScript object whose functions can be invoked without the overhead of serializing .NET data. This can be used in Blazor WebAssembly when performance is crucial:
window.unmarshalledInstance = {
helloWorld: function (personNamePointer) {
const personName = Blazor.platform.readStringField(value, 0);
return `Hello ${personName}`;
}
};var unmarshalledRuntime = (IJSUnmarshalledRuntime)jsRuntime;
var jsUnmarshalledReference = unmarshalledRuntime.InvokeUnmarshalled<IJSUnmarshalledObjectReference>("unmarshalledInstance");
string helloWorldString = jsUnmarshalledReference.InvokeUnmarshalled<string, string>("helloWorld");I haven't tested this out, but I think this should work.
There was a problem hiding this comment.
Sure ... I'll add that on the next commit.
Did you have anything in addition for IJSInProcessObjectReference ☝️?
I think what we have is alright. Maybe we can say it's a reference that's available in |
|
I wouldn't super fret on the example. It's pretty identical to |
|
Ok ... that's what it says now. UPDATE: Merging now. |
Fixes #20068
The main updates here are based on JSObjectReference has been made internal, and IJSObjectReference takes its place in the public API (aspnet/Announcements #435).
Pranav, do you have a few minutes to look this section over? If you don't have time for this right now, I can go ahead and merge these updates without review and then we can revisit this later just before 5.0 hits GA.
I'm mostly concerned about the lack of content for
IJSInProcessObjectReference, which I'm just adding now ...... and I see a bit in the BasicTestApp using it, but I don't feel that that's a good (clear) example.