Skip to content

Commit

Permalink
Merge pull request #10 from KristofferStrube/feature/add-signal-to-st…
Browse files Browse the repository at this point in the history
…reampipeoptions

Add `Signal` to `StreamPipeOptions`.
  • Loading branch information
KristofferStrube authored Mar 10, 2024
2 parents 5810263 + 388d3d2 commit 78f5fe2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="KristofferStrube.Blazor.WebIDL" Version="0.5.0" />
<PackageReference Include="KristofferStrube.Blazor.DOM" Version="0.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.3" />
</ItemGroup>

Expand Down
21 changes: 19 additions & 2 deletions src/KristofferStrube.Blazor.Streams/Options/StreamPipeOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Text.Json.Serialization;
using KristofferStrube.Blazor.DOM;
using KristofferStrube.Blazor.DOM.Abort;
using System.Text.Json.Serialization;

namespace KristofferStrube.Blazor.Streams;

Expand All @@ -7,17 +9,32 @@ namespace KristofferStrube.Blazor.Streams;
/// </summary>
public class StreamPipeOptions
{
/// <summary>
/// Decides whether the destination will be closed when the <see cref="ReadableStream"/> is closed.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
[JsonPropertyName("preventClose")]
public bool PreventClose { get; set; }

/// <summary>
/// Decides whether the destination will be aborted when the <see cref="ReadableStream"/> is aborted.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
[JsonPropertyName("preventAbort")]
public bool PreventAbort { get; set; }

/// <summary>
/// Decides whether the <see cref="ReadableStream"/> will be aborted when the destination is aborted.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
[JsonPropertyName("preventCancel")]
public bool PreventCancel { get; set; }

// TODO: Add AbortSignal signal.
/// <summary>
/// The signal option can be set to an <see cref="AbortSignal"/> to allow aborting an ongoing pipe operation via the corresponding <see cref="AbortController"/>.
/// In this case, this source readable stream will be canceled, and destination aborted, unless the respective options <see cref="PreventCancel"/> or <see cref="PreventAbort"/> are set.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
[JsonPropertyName("signal")]
public AbortSignal? Signal { get; set; }
}

0 comments on commit 78f5fe2

Please sign in to comment.