VDT.Core.Operators 1.0.0

dotnet add package VDT.Core.Operators --version 1.0.0
NuGet\Install-Package VDT.Core.Operators -Version 1.0.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.0.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.0.0
#r "nuget: VDT.Core.Operators, 1.0.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.0.0

// Install VDT.Core.Operators as a Cake Tool
#tool nuget:?package=VDT.Core.Operators&version=1.0.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

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.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 105 3/12/2024
0.6.0 80 2/26/2024
0.5.1 77 2/25/2024
0.5.0 82 2/24/2024
0.4.0 89 2/21/2024
0.3.1 86 2/21/2024
0.3.0 76 2/17/2024
0.2.0 94 2/10/2024
0.1.1 104 2/7/2024
0.1.0 83 2/7/2024

- Add examples
- Add README contents