You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
services.UseWebUSB(); // Makes IUSB available to the DI container
33
+
}
34
+
```
35
+
36
+
### To consume on your `.cshtml`:
37
+
38
+
- On your `_ViewImports.cshtml` add the using entry:
39
+
40
+
```c#
41
+
@usingBlazor.Extensions.WebUSB
42
+
```
43
+
44
+
- Then, on your `.cshtml` inject the `IUSB`:
45
+
46
+
```c#
47
+
@injectIUSBusb
48
+
```
49
+
50
+
And then use the `usb` object to interact with connected USB devices thru your Blazor application.
51
+
52
+
### To inject on a `BlazorComponent` class:
53
+
54
+
Define a property of type `IUSB` and mark it as `[Injectable]`:
55
+
56
+
```c#
57
+
[Inject] privateIUSB_usb { get; set; }
58
+
```
59
+
60
+
Then use the `_usb` variable to interact with the connected USB devices.
61
+
62
+
**Note**: For now, you have to call `await IUSB.Initialize()` once in your application. This is a temporary requirement and we are looking on a better way to automatically register to _Connect/Disconnect_ events.
63
+
64
+
# Contributions and feedback
65
+
66
+
Please feel free to use the component, open issues, fix bugs or provide feedback.
67
+
68
+
# Contributors
69
+
70
+
The following people are the maintainers of the Blazor Extensions projects:
@@ -65,6 +65,13 @@ public Task Disconnected(USBDevice device)
65
65
}
66
66
67
67
// TODO: Find out a more smart way to register to global connect/disconnect events from the WebUSB API regardless if there are subscribers to the events.
0 commit comments