You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, I love what the HybridWebView has introduced into MAUI. However, an immediate issue I encountered is the SetInvokeJavaScriptTarget() method only supports 1 object. If I have many C# classes with methods I want to call from JavaScript, then I would have to write out some duplicate class to pass in.
Have a generator make a source file to pass into SetInvokeJavaScriptTarget()
[Generator]publicclassJsTargetGenerator:IIncrementalGenerator{publicvoidInitialize(IncrementalGeneratorInitializationContextcontext){varmethods=context.SyntaxProvider.ForAttributeWithMetadataName("JsTargetAttribute");varsource=""" public class InvokeJsTarget { public string GetFormFactor() => IFormFactor.GetFormFactor(); public string GetPlatform() => IPlatform.GetPlatform(); } """;context.AddSource(InvokeJsTarget.g.cs,source);}}
Would love to hear everyone's thoughts 🙂
The text was updated successfully, but these errors were encountered:
Hello!
First off, I love what the HybridWebView has introduced into MAUI. However, an immediate issue I encountered is the SetInvokeJavaScriptTarget() method only supports 1 object. If I have many C# classes with methods I want to call from JavaScript, then I would have to write out some duplicate class to pass in.
Related issues: #9424, #27258, #27382
A potential solution is to make a custom attribute
Mark methods across classes and files
Have a generator make a source file to pass into SetInvokeJavaScriptTarget()
Would love to hear everyone's thoughts 🙂
The text was updated successfully, but these errors were encountered: