Skip to content

Update JSObjectReference to IJSObjectReference#20069

Merged
guardrex merged 4 commits intomasterfrom
guardrex-patch-3
Oct 6, 2020
Merged

Update JSObjectReference to IJSObjectReference#20069
guardrex merged 4 commits intomasterfrom
guardrex-patch-3

Conversation

@guardrex
Copy link
Copy Markdown
Collaborator

@guardrex guardrex commented Oct 1, 2020

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 ...

IJSInProcessObjectReference represents a reference to a JavaScript object whose functions can be invoked synchronously.

... and I see a bit in the BasicTestApp using it, but I don't feel that that's a good (clear) example.

  • Do you have a different description that I can drop in? ... or an additional sentence or two to add to that ☝️ for what it is/how it should be used?
  • Do you have a quick (better) example than what's in the BasicTestApp?

@guardrex guardrex requested a review from pranavkm October 1, 2020 13:40
}
```

`IJSInProcessObjectReference` represents a reference to a JavaScript object whose functions can be invoked synchronously.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure ... I'll add that on the next commit.

Did you have anything in addition for IJSInProcessObjectReference ☝️?

@pranavkm
Copy link
Copy Markdown
Contributor

pranavkm commented Oct 2, 2020

Do you have a different description that I can drop in? ... or an additional sentence or two to add to that ☝️ for what it is/how it should be used?

I think what we have is alright. Maybe we can say it's a reference that's available in IJSInProcessRuntime that can call JS apis synchronously.

@pranavkm
Copy link
Copy Markdown
Contributor

pranavkm commented Oct 2, 2020

I wouldn't super fret on the example. It's pretty identical to IJSObjectReference except the calls can by sync. The unmarshalled one is much more interesting since it's both synchronous and avoids the serialization cost.

@guardrex
Copy link
Copy Markdown
Collaborator Author

guardrex commented Oct 2, 2020

Ok ... that's what it says now.

UPDATE: Merging now.

@guardrex guardrex merged commit db45b67 into master Oct 6, 2020
@guardrex guardrex deleted the guardrex-patch-3 branch October 6, 2020 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update JSObjectReference to IJSObjectReference

2 participants