VDT.Core.Operators 1.2.0

dotnet add package VDT.Core.Operators --version 1.2.0                
NuGet\Install-Package VDT.Core.Operators -Version 1.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VDT.Core.Operators" Version="1.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VDT.Core.Operators --version 1.2.0                
#r "nuget: VDT.Core.Operators, 1.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install VDT.Core.Operators as a Cake Addin
#addin nuget:?package=VDT.Core.Operators&version=1.2.0

// Install VDT.Core.Operators as a Cake Tool
#tool nuget:?package=VDT.Core.Operators&version=1.2.0                

VDT.Core.Operators

Operators that process streams of published values from operand streams, allowing you to subscribe to the output stream for handling any sorts of events in a streamlined way. Create operand streams of the types you want to process, apply the required operators to those streams and subscribe to the results. Conceptually this is similar to piping observables, except an operand stream doesn't own the data it publishes - it's merely a conduit that's used for publishing, piping and subscribing. Below example uses a series of operators to ensure string values don't get published more than once every half a second and can be parsed as integers before subscribing to the resulting integer stream.

Features

  • Asynchronous subscription to streams of values
  • Asynchronous piping of values through a variety of operators to transform them
  • Easily extensible with your own operators

Options

Each operand stream can be provided with an OperandStreamOptions object to specify how subscribers are interacted with.

  • ReplayWhenSubscribing toggles the setting to publish all previously published values to a new subscriber when it is added

Operators

  • Debounce delays and throttles output values
  • Filter discards output values based on a predicate
  • Flatten subscribes to a stream of streams and outputs values published by the child streams
  • GroupBy groups published values by using a key selector
  • Iterate loops over received values of IEnumerable<T>
  • Map transforms values
  • Merge merges two or more streams
  • QueueThrottle throttles output, queueing received values
  • QueueZip outputs tuples of values published by two streams, queueing received values
  • Throttle throttles output, discarding old received values
  • Zip outputs tuples of values published by two streams, discarding old received values

Example

Below example uses a series of operators to ensure string values don't get published more than once every half a second and can be parsed as integers before subscribing to the resulting integer stream.

&lt;input type="text" @oninput="async args => await valueStream.Publish(args.Value!.ToString()!)" /&gt;

@code {
    private readonly IOperandStream&lt;string&gt; valueStream = new OperandStream&lt;string&gt;();

    protected override void OnAfterRender(bool firstRender) {
        if (firstRender) {
            valueStream
                .Debounce(500)
                .Map(value => new { IsValid = int.TryParse(value, out var result), Result = result })
                .Filter(value => value.IsValid)
                .Map(value => value.Result)
                .Subscribe(value => {
                    // Handle received integer values
                });
        }
    }
}

Custom operators

Although many common operators are available out of the box, it is simple to create your own by implementing either IOperator&lt;TValue, TTransformedValue&gt; to transform values without any initialization, or IOperator&lt;TValue, TTransformedValue, TInitializationData&gt; to add an initialization method with data to the operator. For ease of use, you can then also create extension methods for IOperandStream&lt;TValue&lt; that pipes values through your operator to the target stream.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on VDT.Core.Operators:

Package Downloads
VDT.Core.Blazor.XYChart

Blazor component to create SVG charts with a category X-axis and a value Y-axis such as bar, line and area charts

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 104 6/9/2024
1.1.0 103 5/17/2024
1.0.0 278 3/12/2024
0.6.0 118 2/26/2024
0.5.1 126 2/25/2024
0.5.0 117 2/24/2024
0.4.0 123 2/21/2024
0.3.1 120 2/21/2024
0.3.0 111 2/17/2024
0.2.0 125 2/10/2024
0.1.1 140 2/7/2024
0.1.0 118 2/7/2024

- Add options with support for replaying published values to new subscribers