Might be a silly question. But is there a way to re-use methods that call Javascript functions in runtime?
So let's say I have EditBox.razor
component that has this function
@inject IJSRuntime JSRuntime
...
Some HTML code
...
@code{
...
private async Task RenderSyntax()
{
await JSRuntime.InvokeVoidAsync("Prism.highlightAll");
}
...
Now I want to call this method in some other component Foo.razor
. Without having reference, so statically.
Do I create a static class model for generic Javascript.razor
components where I define all my javascript interops that are called by different components and make all other components inherit it?