diff --git a/samples/KristofferStrube.Blazor.Streams.WasmExample/Pages/Index.razor b/samples/KristofferStrube.Blazor.Streams.WasmExample/Pages/Index.razor index eb2a2f4..a64c498 100644 --- a/samples/KristofferStrube.Blazor.Streams.WasmExample/Pages/Index.razor +++ b/samples/KristofferStrube.Blazor.Streams.WasmExample/Pages/Index.razor @@ -1,4 +1,5 @@ @page "/" +@using KristofferStrube.Blazor.WebIDL @inject IJSInProcessRuntime JSRuntime Streams - Index @@ -15,7 +16,7 @@ Using the reader we read the chunks until there are no more. } @code { - private List chunkSizes = new(); + private List chunkSizes = new(); private int dataSize = 1000 * 1024; protected override async Task OnInitializedAsync() @@ -28,7 +29,12 @@ Using the reader we read the chunks until there are no more. ReadableStreamReadResultInProcess read = await readableStreamReader.ReadAsync(); while (!read.Done) { - var length = await JSRuntime.InvokeAsync("getAttribute", read.Value, "length"); + await using Uint8ArrayInProcess chunk = await Uint8ArrayInProcess.CreateAsync( + JSRuntime, + read.Value, + new() { DisposesJSReference = true } + ); + var length = chunk.Length; chunkSizes.Add(length); await Task.Delay(100); await read.DisposeAsync(); diff --git a/src/KristofferStrube.Blazor.Streams/ReadableStream/ReadableStreamReadResult.InProcess.cs b/src/KristofferStrube.Blazor.Streams/ReadableStream/ReadableStreamReadResult.InProcess.cs index f0c1879..3829bbc 100644 --- a/src/KristofferStrube.Blazor.Streams/ReadableStream/ReadableStreamReadResult.InProcess.cs +++ b/src/KristofferStrube.Blazor.Streams/ReadableStream/ReadableStreamReadResult.InProcess.cs @@ -35,8 +35,8 @@ internal ReadableStreamReadResultInProcess(IJSRuntime jSRuntime, IJSInProcessObj /// /// A JS Reference to a chunk of data. /// - /// A to a value which can be of any type. - public IJSObjectReference Value => inProcessHelper.Invoke("getAttribute", JSReference, "value"); + /// An to a value which can be of any type. + public IJSInProcessObjectReference Value => inProcessHelper.Invoke("getAttribute", JSReference, "value"); /// /// Indicates whether this is the last read which means that will be undefined.