RoomSharp.Reactive 0.5.5

dotnet add package RoomSharp.Reactive --version 0.5.5
                    
NuGet\Install-Package RoomSharp.Reactive -Version 0.5.5
                    
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="RoomSharp.Reactive" Version="0.5.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RoomSharp.Reactive" Version="0.5.5" />
                    
Directory.Packages.props
<PackageReference Include="RoomSharp.Reactive" />
                    
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 RoomSharp.Reactive --version 0.5.5
                    
#r "nuget: RoomSharp.Reactive, 0.5.5"
                    
#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 RoomSharp.Reactive@0.5.5
                    
#: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=RoomSharp.Reactive&version=0.5.5
                    
Install as a Cake Addin
#tool nuget:?package=RoomSharp.Reactive&version=0.5.5
                    
Install as a Cake Tool

RoomSharp.Reactive

Lightweight reactive operators, computed views, query caching, UI collection binding, and Rx.NET adapters for RoomSharp.

Installation

dotnet add package RoomSharp.Reactive

Observe + debounce

using RoomSharp.Reactive;

var todos = db.GetTableIdOrThrow("todos");

// Default debounce uses ReactiveDefaults.DefaultDebounceInterval (150ms)
var query = db.ObserveReactive(
    ct => new ValueTask<IReadOnlyList<Todo>>(db.TodoDao.GetAllAsync()),
    new ReactiveQueryOptions
    {
        DebounceInterval = TimeSpan.FromMilliseconds(200)
    },
    todos);

using var subscription = query.Subscribe(
    list => Render(list),
    error => Log(error));

QueryCache (single-flight + TTL)

using RoomSharp.Reactive;

var cache = new QueryCache(db, new QueryCacheOptions
{
    DefaultTtl = TimeSpan.FromSeconds(30),
    MaxEntries = 1_000,
    FactoryCancellationMode = CacheFactoryCancellationMode.NeverCancelInFlight
});
var key = db.BuildCacheKey<IReadOnlyList<Todo>>("select * from todos", parameters: null);

var cached = db.ObserveCached(
    cache,
    key,
    ct => new ValueTask<IReadOnlyList<Todo>>(db.TodoDao.GetAllAsync()),
    new QueryCacheEntryOptions
    {
        Ttl = TimeSpan.FromSeconds(10),
        TableIds = new[] { db.GetTableIdOrThrow("todos") }
    },
    options: null,
    db.GetTableIdOrThrow("todos"));

using var sub = cached.Subscribe(
    list => Render(list),
    error => Log(error));

QueryCache uses single-flight execution for concurrent requests with the same key, TTL expiration, table invalidation, and a bounded entry count. Completed entries over MaxEntries are evicted from the oldest-accessed entries first; in-flight factories are not evicted.

FactoryCancellationMode controls how caller cancellation affects the shared factory:

  • NeverCancelInFlight keeps the shared factory running even if one waiter cancels. This is the default and is usually best for UI screens.
  • LinkedToFirstCaller links the factory to the first caller cancellation token. Use it only when cancelled first callers should abandon shared work.

For operational telemetry, implement IQueryCacheMetrics2 to receive eviction reasons, active entry counts, and factory duration/failure callbacks.

ComputedView (derived reactive value)

using RoomSharp.Reactive;

var todosQuery = db.ObserveReactive(
    ct => new ValueTask<IReadOnlyList<Todo>>(db.TodoDao.GetAllAsync()),
    db.GetTableIdOrThrow("todos"));

var stats = ComputedView.Combine(
    todosQuery,
    todos => new TodoStats(todos.Count),
    new ComputedViewOptions
    {
        DebounceInterval = TimeSpan.FromMilliseconds(200)
    });

using var sub = stats.Subscribe(
    value => UpdateStats(value),
    error => Log(error));

ObservableCollection binding (WPF/WinUI)

using RoomSharp.Reactive;
using System.Collections.ObjectModel;
using System.Threading;

var collection = new ReactiveObservableCollection<Todo>();
var ui = SynchronizationContext.Current!;

using var sub = query
    .AsObservable()
    .BindToObservableCollection(
        collection,
        new ReactiveCollectionBindingOptions<Todo>
        {
            Dispatch = action => ui.Post(_ => action(), null),
            KeySelector = todo => todo.Id,
            UpdateMode = ReactiveCollectionUpdateMode.Reset,
            MergeExisting = (existing, incoming) =>
            {
                existing.Title = incoming.Title;
                existing.IsDone = incoming.IsDone;
            },
            OnError = error => Log(error)
        });

ReactiveObservableCollection<T> can replace or merge a full result set with one reset notification. This is useful for larger UI lists where per-item collection notifications create unnecessary UI work.

Diagnostics

Reactive refreshes, cache factories, and collection binding updates publish ActivitySource spans through RoomSharp.Reactive:

using System.Diagnostics;

using var listener = new ActivityListener
{
    ShouldListenTo = source => source.Name == ReactiveDiagnostics.ActivitySourceName,
    Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllDataAndRecorded
};

ActivitySource.AddActivityListener(listener);

The activities include tags such as table count, subscriber count, item count, cache key hash, active entries, and factory duration.

Lightweight operators

using RoomSharp.Reactive;

var stream = query
    .AsObservable()
    .DistinctUntilChanged()
    .Throttle(TimeSpan.FromMilliseconds(150))
    .Buffer(TimeSpan.FromMilliseconds(250));

Rx.NET integration

using RoomSharp.Reactive.Rx;

var observable = query.ToObservable();
observable
    .Throttle(TimeSpan.FromMilliseconds(300))
    .DistinctUntilChanged()
    .Subscribe(list => Render(list));

Requirements

  • RoomSharp 0.4.3+
  • System.Reactive 6.0+ is referenced transitively by this package for Rx.NET adapters.
Product Compatible and additional computed target framework versions.
.NET 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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on RoomSharp.Reactive:

Package Downloads
RoomSharp.Reactive.WinForms

WinForms UI binding helpers for RoomSharp.Reactive (BindingList, BindingSource, DataGridView).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.5 44 5/10/2026
0.5.4 101 5/1/2026
0.5.3 96 4/30/2026
0.5.2 106 4/28/2026
0.5.1 102 4/27/2026
0.5.0 107 4/20/2026
0.4.7 121 1/15/2026
0.4.6 116 1/11/2026
0.4.5 122 1/3/2026
0.4.4 116 12/26/2025
0.4.3 268 12/19/2025