-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Dereference the result of createJSObjectReference from JavaScript #56200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Sorry was just looking at the original post (linked in the issue description) and noticed it had been prematurely closed with multiple comments still unanswered |
@Yannike what do you exactly mean by dereferencing? Do you mean accessing a property of the JSObjectReference directly? You might be looking for #31151 which is not currently supported. You need to add a method to your object so that it can be called that way If you give us an example in code that might help us understand what you are trying to accomplish. |
So here is my situation. I have a javascript object that is not Json serializable. I want to be able to keep a reference to the object on the c# side and send it back to Javascript to call on method on the object. for example the object could be created on the js (typescript) side with this :
on the blazor side
I want to call a test method that take the object reference as a parameter and that is able to use this object in javascript. So far I haven't manage to make it work. |
@Yannike thanks for the additional details. What is If its a dotnet object that you are passing down to JS, you need to use |
Sorry Javier, the this.objectReference should be jsObjectReference, so the reference returned from JavaScript |
@Yannike thanks for the additional details. So, to make sure that we understand what you are trying to do, will you say that the following sequence accurately represents what you are trying to do? sequenceDiagram
Dotnet ->> JS: JSObjectReference reference = await JSRuntime.InvokeAsync("GetJSObjectReference")
JS -->> Dotnet: return [JSObjectReference]
Dotnet ->> JS: var result = reference.Invoke("Test", reference)
break
Dotnet --> JS: JS Interop error
end
|
Yes that is exactly what I am trying to do. Nicely described ! |
@Yannike thanks for the additional details. From what I can tell looking at the code, this should work. Can you provide a minimal repro project as a public github repository that demonstrates the issue? There might be small details that are different that we aren't mentioning explicitly here. |
Hi @Yannike. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Thank you for filing this issue. In order for us to investigate this issue, please provide a minimal repro project that illustrates the problem without unnecessary code. Please share with us in a public GitHub repo because we cannot open ZIP attachments, and don't include any confidential content. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate. See our Issue Management Policies for more information. |
Originally posted by @Yannike in #53161 (comment)
The text was updated successfully, but these errors were encountered: