MicrosoftEdge / MicrosoftEdge/WebView2Feedback

WebView2 corespondent for CefSharp IJavascriptCallback

Open
#2,632 5 comments 1 reaction 1 assignee View on GitHub

@david-risney is already working on this.

Since Jul 28, 2022.

bug tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

I am using Microsoft.Web.WebView2 version 1.0.1185.39.

I have an object in C# that I use AddHostObjectToScript("MyObject", new MyObject()); to add it to the browser.

This was one of the methods from MyObject.cs in C#

 public string ExecuteTask(bool full, IJavascriptCallback callback= null)
 {
   Task.Run(() =>
            {
                    ( ... do stuff ...)
                    callback.ExecuteAsync(result);
            });
 return "";
 }

===================================
And this was the javascript code:

var objectCS = window["MyObject"];
            return new Promise((resolve) => {
                objectCS .ExecuteTask(full, (response) => {
                    var responseParsed = JSON.parse(response);
                    resolve(responseParsed );
              });
});

===================================

My problem is that I do not know for WebView2, what value should the callback parameter from C# have.
Any idea is very much appreciated

AB#40833899

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.