Eilon / MauiHybridWebView

MIT License
206 stars 44 forks source link

Ignore null values in InvokeJSMethodAsync while serializing #72

Closed ranjwarrior closed 1 month ago

ranjwarrior commented 1 month ago

Thank you for this awesome work! Would it be possible to make InvokeJsMethodAsync configurable. We have a scenario where we need this code snippet in HybridWebView.cs for our React component to display a form correctly:

        return await EvaluateJavaScriptAsync($"{methodName}({(paramValues == null ? string.Empty : string.Join(", ", paramValues.Select(v => JsonConvert.SerializeObject(v, new JsonSerializerSettings
        {
            NullValueHandling = NullValueHandling.Ignore
        }))))})");

instead of

return await EvaluateJavaScriptAsync($"{methodName}({(paramValues == null ? string.Empty : string.Join(", ", paramValues.Select(v => JsonSerializer.Serialize(v))))})");

Thanks!

ranjwarrior commented 1 month ago

Thanks!