DevBitsLab.Feeds 0.0.2

There is a newer version of this package available.
See the version list below for details.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package DevBitsLab.Feeds --version 0.0.2
                    
NuGet\Install-Package DevBitsLab.Feeds -Version 0.0.2
                    
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="DevBitsLab.Feeds" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DevBitsLab.Feeds" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="DevBitsLab.Feeds" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DevBitsLab.Feeds --version 0.0.2
                    
#r "nuget: DevBitsLab.Feeds, 0.0.2"
                    
#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.
#:package DevBitsLab.Feeds@0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DevBitsLab.Feeds&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=DevBitsLab.Feeds&version=0.0.2
                    
Install as a Cake Tool

DevBitsLab.Feeds

A reactive data management library for .NET that provides state-aware feeds with automatic loading, error handling, and incremental change tracking for collections.

CI .NET 10 C# 14 License: MIT

๐Ÿ“– Overview

DevBitsLab.Feeds is a reactive data management library that simplifies working with asynchronous data in .NET applications. It provides a unified approach to handling loading states, errors, and data updates through a composable feed abstraction.

Key Benefits

  • Simplified State Management: Automatic tracking of loading, error, and value states
  • Reactive Updates: Event-driven architecture for real-time UI synchronization
  • Incremental Collection Updates: Efficient list change tracking for optimal UI performance
  • Type-Safe Composition: Combine multiple data sources with compile-time type checking
  • MVVM-Ready: Built-in support for ICommand integration and data binding

๐Ÿ“š Documentation

๐Ÿ“– Full API Documentation โ€” Detailed guides for all classes and interfaces

Quick Links
Feed<T> Single-value reactive feed
ListFeed<T> Reactive list with change tracking
State<T> Editable state with validation
CombinedFeed Combine multiple feeds

๐Ÿ“‹ Requirements

  • .NET 10.0 or later
  • C# 14 (Preview)
  • Nullable Reference Types enabled

๐Ÿ“ฆ Installation

.NET CLI

dotnet add package DevBitsLab.Feeds

Package Manager Console

Install-Package DevBitsLab.Feeds

๐Ÿš€ Getting Started

Basic Feed Usage

using DevBitsLab.Feeds;

// Create a feed that loads data from an API
var customerFeed = Feed<Customer>.Create(async ct =>
{
    return await httpClient.GetFromJsonAsync<Customer>($"/api/customers/{id}", ct);
});

// Subscribe to state changes
customerFeed.StateChanged += (sender, e) =>
{
    if (customerFeed.IsLoading)
        ShowLoadingSpinner();
    else if (customerFeed.HasValue)
        DisplayCustomer(customerFeed.Value!);
    else if (customerFeed.HasError)
        ShowError(customerFeed.Error!.Message);
};

// Or await the feed directly
var customer = await customerFeed;

List Feed with Change Tracking

var productsFeed = ListFeed<Product>.Create(async ct =>
{
    return await productApi.GetProductsAsync(ct);
});

// Subscribe to incremental changes
productsFeed.ItemsChanged += (sender, e) =>
{
    switch (e.Change)
    {
        case ListChange<Product>.ItemAdded added:
            InsertRowAt(added.Index, added.Item);
            break;
        case ListChange<Product>.ItemRemoved removed:
            RemoveRowAt(removed.Index);
            break;
    }
};

// Modify the list - changes are tracked automatically
productsFeed.Add(new Product { Name = "New Product" });

Editable State with Validation

var settingsState = State<Settings>.Create(
    loadFunc: async ct => await settingsService.LoadAsync(ct),
    saveFunc: async (settings, ct) => await settingsService.SaveAsync(settings, ct),
    validateFunc: settings =>
    {
        var result = new ValidationResult();
        if (string.IsNullOrWhiteSpace(settings?.Username))
            result.AddError(nameof(Settings.Username), "Username is required");
        return result;
    });

// Edit and save
settingsState.Update(settingsState.Value! with { Theme = "Dark" });

if (settingsState.IsDirty && !settingsState.HasErrors)
    await settingsState.SaveAsync();

๐Ÿ”ง Core Types

Type Description
Feed<T> Reactive feed for single values with async loading
ListFeed<T> Reactive list with incremental change notifications
State<T> Editable wrapper with dirty tracking and validation
ValidationResult Property-level validation errors
CombinedFeed Combines multiple feeds into one

๐Ÿ“Œ Feed States

State Description
None Initial state - no data loaded
Loading Currently fetching data
HasValue Data successfully loaded
HasError Error occurred during loading
Refreshing Updating existing data
Retrying Retrying after error

๐Ÿ“š API Quick Reference

Feed Methods

  • Create(loadFunc) - Create auto-loading feed
  • CreateDeferred(loadFunc) - Create manually-triggered feed
  • FromValue(value) - Create feed with existing value
  • FromError(exception) - Create feed in error state
  • RefreshAsync() - Reload data from source
  • Select(selector) - Transform feed value

ListFeed Methods

  • Empty() - Create empty list feed
  • FromItems(items) - Create from existing items
  • Add(item) / Insert(index, item) - Add items
  • Remove(item) / RemoveAt(index) - Remove items
  • Update(index, newItem) - Replace item
  • BatchUpdate(action) - Atomic multi-operation

State Methods

  • Update(value) - Set new value (marks dirty)
  • SaveAsync() - Persist changes
  • RevertAsync() - Discard changes
  • Reset(value) - Set value without dirty flag

LINQ Extensions

  • Select(selector) - Project items
  • Where(predicate) - Filter items
  • OrderBy(keySelector) - Sort items
  • Take(count) / Skip(count) - Pagination
  • Aggregate(aggregator) - Compute aggregate value

โœ… Best Practices

1. Always Dispose Feeds

public class MyViewModel : IDisposable
{
    private readonly Feed<Data> _feed;
    public void Dispose() => _feed?.Dispose();
}

2. Batch Multiple List Changes

// Good: Single notification
listFeed.BatchUpdate(editor =>
{
    editor.Add(item1);
    editor.Add(item2);
});

3. Combine Feeds for Derived Data

var dashboardFeed = userFeed.CombineWith(
    ordersFeed,
    (user, orders) => new Dashboard(user, orders));

๐Ÿ“Š Benchmark Results

Benchmarks run nightly. Run configuration: .NET 10, Release mode, Ubuntu Latest.

See the main repository README for full benchmark details.

Feed Throughput

Operation Mean Throughput Allocated
Access Feed.Value 0.002 ns ~500B ops/sec -
Access Feed.HasValue 0.23 ns ~4.4B ops/sec -
Feed.UpdateValue 1.95 ns ~513M ops/sec -
Feed.Pause/Resume 1.97 ns ~508M ops/sec -
Create deferred Feed 20.19 ns ~50M ops/sec 120 B
Create Feed.FromValue 33.92 ns ~29M ops/sec 208 B
Feed await (cached) 39.95 ns ~25M ops/sec 176 B
Feed.Select transformation 82.05 ns ~12M ops/sec 360 B

ListFeed Throughput

Operation Mean Throughput Allocated
Access ListFeed.Count 9.67 ns ~103M ops/sec -
Access ListFeed.Value 10.47 ns ~96M ops/sec -
Create ListFeed.Empty 23.40 ns ~43M ops/sec 168 B
Create FromItems (10) 34.68 ns ~29M ops/sec 232 B
Create FromItems (100) 49.33 ns ~20M ops/sec 592 B
Create FromItems (1000) 248.35 ns ~4M ops/sec 4,192 B
ListFeed.Update 2.45 ยตs ~408K ops/sec -
ListFeed.Add 3.30 ยตs ~303K ops/sec -
ListFeed.BatchUpdate (10 ops) 7.02 ยตs ~142K ops/sec -

State Throughput

Operation Mean Throughput Allocated
State.MarkDirty 0.08 ns ~12.5B ops/sec -
Access State.IsDirty 0.24 ns ~4.2B ops/sec -
Access State.Value 0.89 ns ~1.1B ops/sec -
State.Update (same value) 1.17 ns ~855M ops/sec -
State.GetErrors 22.07 ns ~45M ops/sec 64 B
Create State.FromValue 129.91 ns ~7.7M ops/sec 736 B
State.Reset 2.71 ยตs ~369K ops/sec -
State.Update (new value) 3.79 ยตs ~264K ops/sec -
State.Update with validation 8.64 ยตs ~116K ops/sec -

Key Performance Characteristics

  • Zero-allocation reads: Accessing Value, State, IsDirty, HasValue allocates nothing
  • Sub-nanosecond property access: Core read operations complete in under 1 ns
  • Efficient updates: Single-item operations complete in nanoseconds
  • Scalable collections: ListFeed<T> operations scale well with collection size
  • Batch optimization: BatchUpdate amortizes notification overhead across multiple operations

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

  1. Clone the repository
  2. Open in Visual Studio 2022 or later
  3. Build the solution
  4. Run tests

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

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

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DevBitsLab.Feeds:

Package Downloads
DevBitsLab.Feeds.WinUI

WinUI extensions for DevBitsLab.Feeds including FeedPresenter control for automatic feed state presentation and ISupportIncrementalLoading support for virtualized list loading.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.10 104 1/19/2026
0.0.8 93 1/19/2026
0.0.7 94 1/19/2026
0.0.6 101 1/18/2026
0.0.5 96 1/14/2026

Initial release of DevBitsLab.Feeds with Feed<T>, ListFeed<T>, State<T>, and CombinedFeed support.