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

Microsoft.Interop.JSRuntime.Current has been removed #347

Open
pranavkm opened this Issue Mar 2, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@pranavkm
Copy link
Member

pranavkm commented Mar 2, 2019

In ASP.NET Core 3.0.0-preview3, we are removing the ability to access the Microsoft.Interop.IJSRuntime via the static JSRuntime.Current property. Application users may continue to access the IJSRuntime instance by injecting it in to their components. For example,

Previously:

// Stock.cshtml
@functions {
    
    public override void OnInit()
    {
        StocksService.OnStockTickerUpdated += stockUpdate =>
        {
            JSRuntime.Current.InvokeAsync<object>(
                "handleTickerChanged", stockUpdate.symbol, stockUpdate.price);
        };
    }
}

After 3.0.0-preview3,

// Stock.cshtml
@inject IJSRuntime JSRuntime

@functions {
    
    public override void OnInit()
    {
        StocksService.OnStockTickerUpdated += stockUpdate =>
        {
            JSRuntime.InvokeAsync<object>(
                "handleTickerChanged", stockUpdate.symbol, stockUpdate.price);
        };
    }
}

Related issue: aspnet/AspNetCore#6828

Please use aspnet/AspNetCore#8117 for discussions.

@pranavkm pranavkm added this to the 3.0.0-preview3 milestone Mar 2, 2019

@aspnet aspnet locked and limited conversation to collaborators Mar 2, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.