From the course: Blazor: Getting Started

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Call Blazor from JavaScript

Call Blazor from JavaScript - Blazor Tutorial

From the course: Blazor: Getting Started

Start my 1-month free trial

Call Blazor from JavaScript

- [Narrator] Since the beam animation is so mesmerizing, I want the application to let the user know how many times they've watched the beam go by, we can have JavaScript call back to our application to register each time the animation completes. Because of the nature of JavaScript calling into the dotnet runtime from a dynamically typed language to a statically typed one, there are some restrictions, the method must either be static, or pass a reference of itself into JavaScript. There isn't a way for blazer to find a particular instance of a class to execute a method if we don't send it one. And if we do send it a reference to call, we have to ensure that it's disposed of properly. The method can't use generic arguments overloads or interface types, because the types of the arguments are used to deserialize the incoming data, which brings us to the last restriction. The parameters have to be deserializable from JSON…

Contents