VDT.Core.Operators
1.0.0
See the version list below for details.
dotnet add package VDT.Core.Operators --version 1.0.0
NuGet\Install-Package VDT.Core.Operators -Version 1.0.0
<PackageReference Include="VDT.Core.Operators" Version="1.0.0" />
paket add VDT.Core.Operators --version 1.0.0
#r "nuget: VDT.Core.Operators, 1.0.0"
// 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 valuesFilter
discards output values based on a predicateFlatten
subscribes to a stream of streams and outputs values published by the child streamsGroupBy
groups published values by using a key selectorIterate
loops over received values ofIEnumerable<T>
Map
transforms valuesMerge
merges two or more streamsQueueThrottle
throttles output, queueing received valuesQueueZip
outputs tuples of values published by two streams, queueing received valuesThrottle
throttles output, discarding old received valuesZip
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.
<input type="text" @oninput="async args => await valueStream.Publish(args.Value!.ToString()!)" />
@code {
private readonly IOperandStream<string> valueStream = new OperandStream<string>();
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<TValue, TTransformedValue>
to transform values without any initialization, or
IOperator<TValue, TTransformedValue, TInitializationData>
to add an initialization method with data to the operator. For ease of use, you can then also
create extension methods for IOperandStream<TValue<
that pipes values through your operator to the target stream.
Product | Versions 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. |
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
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.
- Add examples
- Add README contents