Skip to content
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

HybridWebView: Add support for C# to invoke JavaScript methods #22303

Closed
Eilon opened this issue May 8, 2024 · 1 comment
Closed

HybridWebView: Add support for C# to invoke JavaScript methods #22303

Eilon opened this issue May 8, 2024 · 1 comment
Labels
area-controls-hybridwebview HybridWebView control fixed-in-9.0.0-rc.1.24453.9 s/triaged Issue has been reviewed t/enhancement ☀️ New feature or request
Milestone

Comments

@Eilon
Copy link
Member

Eilon commented May 8, 2024

Add a few new methods to enable C# code to invoke a JavaScript method:

		/// <summary>
		/// Invokes a JavaScript method named <paramref name="methodName"/> and optionally passes in the parameter values
		/// specified by <paramref name="paramValues"/>.
		/// </summary>
		/// <param name="methodName">The name of the JavaScript method to invoke.</param>
		/// <param name="paramValues">Optional array of objects to be passed to the JavaScript method.</param>
		/// <returns>A string containing the return value of the called method.</returns>
		public async Task<string?> InvokeJavaScriptAsync(string methodName, params object[] paramValues) { ... }

		/// <summary>
		/// Invokes a JavaScript method named <paramref name="methodName"/> and optionally passes in the parameter values specified
		/// by <paramref name="paramValues"/> by JSON-encoding each one.
		/// </summary>
		/// <typeparam name="TReturnType">The type of the return value to deserialize from JSON.</typeparam>
		/// <param name="methodName">The name of the JavaScript method to invoke.</param>
		/// <param name="paramValues">Optional array of objects to be passed to the JavaScript method by JSON-encoding each one.</param>
		/// <returns>An object of type <typeparamref name="TReturnType"/> containing the return value of the called method.</returns>
		public async Task<TReturnType?> InvokeJavaScriptAsync<TReturnType>(string methodName, params object[] paramValues) { ... }

		/// <summary>
		/// Runs the JavaScript code provided in the <paramref name="script"/> parameter and returns the result as a string.
		/// </summary>
		/// <param name="script">The JavaScript code to run.</param>
		/// <returns>The return value (if any) of running the script.</returns>
		public async Task<string?> EvaluateJavaScriptAsync(string script) { ... }
@Eilon Eilon added t/enhancement ☀️ New feature or request area-controls-hybridwebview HybridWebView control labels May 8, 2024
@Eilon Eilon added this to the .NET 9 Planning milestone May 8, 2024
@dotnet-policy-service dotnet-policy-service bot added the s/triaged Issue has been reviewed label May 8, 2024
@samhouts samhouts removed the s/triaged Issue has been reviewed label Jul 3, 2024
@samhouts samhouts added the s/triaged Issue has been reviewed label Jul 10, 2024
Eilon added a commit that referenced this issue Jul 23, 2024
Eilon added a commit that referenced this issue Jul 26, 2024
Eilon added a commit that referenced this issue Aug 6, 2024
Eilon added a commit that referenced this issue Aug 14, 2024
@Eilon
Copy link
Member Author

Eilon commented Sep 6, 2024

Fixed by #23769

@Eilon Eilon closed this as completed Sep 6, 2024
@Eilon Eilon modified the milestones: .NET 9 Planning, 9.0-rc1 Sep 6, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Oct 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-hybridwebview HybridWebView control fixed-in-9.0.0-rc.1.24453.9 s/triaged Issue has been reviewed t/enhancement ☀️ New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants