public async Task <AmbientLightSensor> StartReading(Action onReading) { var requestId = Guid.NewGuid(); AmbientLightSensor sensor = new AmbientLightSensor(requestId); sensor.OnReading = onReading; _activeSensors.Add(requestId, sensor); await JSRuntime.Current.InvokeAsync <string>( "AspNetMonsters_Blazor_Sensors.startAmbientLightSensor", new DotNetObjectRef(this), requestId); return(sensor); }
public async Task StopReading(AmbientLightSensor sensor) { await JSRuntime.Current.InvokeAsync <string>( "AspNetMonsters_Blazor_Sensors.stopAmbientLightSensor", sensor.Id); }