To use bit Bup, please follow these steps:
- Install the
Bit.Bupnuget package
dotnet add package Bit.Bup- In the default document (
index.html,_Host.cshtml, or_Layout.cshtml), add anautostart="false"attribute and value to the script tag of the Blazor script.
<script src="_framework/blazor.webassembly.js" autostart="false"></script>- Also In the default document (
index.html,_Host.cshtml, or_Layout.cshtml), add theBit.Bupreference after the script tag of the Blazor script.
<script src="_content/Bit.Bup/bit-bup.js" log="verbose" handler="bitBupHandler"></script>log: The log level of the bit Bup logger. available options are:info,verbose,debug, anderror. (not implemented yet)handler: The name of the handler function for the bit Bup events.
You can remove any of these attributes, and use the default values mentioned above.
- Add a handler function like the below code to handle multiple events of the bit Bup, or you can follow the full sample code which is provided in the Demo projects of this repo.
function bitBupHandler(type, data) {
switch (type)
{
case 'start':
return console.log('downloading started.');
case 'progress':
return console.log('resource downloaded:', data);
case 'end':
return console.log('downloading ended.');
}
}