ListenableAsyncEnumerable 1.0.0

dotnet add package ListenableAsyncEnumerable --version 1.0.0                
NuGet\Install-Package ListenableAsyncEnumerable -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="ListenableAsyncEnumerable" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ListenableAsyncEnumerable --version 1.0.0                
#r "nuget: ListenableAsyncEnumerable, 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 ListenableAsyncEnumerable as a Cake Addin
#addin nuget:?package=ListenableAsyncEnumerable&version=1.0.0

// Install ListenableAsyncEnumerable as a Cake Tool
#tool nuget:?package=ListenableAsyncEnumerable&version=1.0.0                

ListenableAsyncEnumerable is a C# implementation of Darts Stream infrastructure.

For now, only basic functionality is covered.

IListenableAsyncEnumerable<T>

To obtain an IListenableAsyncEnumerable<T>, call the ToListenable extension method on any IAsyncEnumerable<T>:

IAsyncEnumerable<string> enumerable = GetMyAsyncEnumerable();
IListenableAsyncEnumerable<string> listenable = enumerable.ToListenable();

IAsyncEnumerableSubscription<T>

Call the Listen method on an IListenableAsyncEnumerable<T> to obtain an IAsyncEnumerableSubscription<T>:

using IAsyncEnumerableSubscription<string> subscription = listenable.Listen(
    onData: value => HandleMyValue(value),
    onError: exception => HandleException(exception),
    onDone: () => HandleRiverDone()
);

await foreach (var value in listenable) {
    // Do something with the value
}

// Cancel the subscription if you don't need it anymore
// It will also get cancelled when Dispose is called
subscription.Cancel();

Calling Listen will not enumerate the enumerable. The callbacks passed to the Listen method only get invoked once the enumerable actually gets enumerated.

Contributions

Contributions are welcome. Open an issue or a PR if you want.

License

This project is licensed under the MIT license.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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 was computed.  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.
  • net7.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 222 7/18/2023

Initial release