NeHive.Reactive
0.1.1
dotnet add package NeHive.Reactive --version 0.1.1
NuGet\Install-Package NeHive.Reactive -Version 0.1.1
<PackageReference Include="NeHive.Reactive" Version="0.1.1" />
<PackageVersion Include="NeHive.Reactive" Version="0.1.1" />
<PackageReference Include="NeHive.Reactive" />
paket add NeHive.Reactive --version 0.1.1
#r "nuget: NeHive.Reactive, 0.1.1"
#:package NeHive.Reactive@0.1.1
#addin nuget:?package=NeHive.Reactive&version=0.1.1
#tool nuget:?package=NeHive.Reactive&version=0.1.1
NeHive.Reactive
A lightweight high-performance reactive runtime for .NET, built on a single-threaded dependency graph model with signal-driven fine-grained state updates.
This project is in early development (0.1.x series). APIs are subject to change.
Overview
NeHive.Reactive is a lightweight high-performance single-threaded reactive runtime for .NET.
Built on a scope dependency graph + signal propagation architecture, it follows the fine-grained reactivity model popularized by SolidJS and Vue3, while remaining fully native to C#.
No reflection.
No heavy runtime dependencies.
Low GC overhead.
Designed for declarative UI systems, reactive state management, and business flow orchestration, it also serves as the core runtime engine of NeHive.UI.
Core Design Principles
🧭 Scope Isolation
Scopemanages reactive resources and lifecycles uniformly, preventing memory leaks caused by unmanaged subscriptions.⚡ Fine-Grained Reactivity
Dependencies are tracked precisely. Only affected logic is updated instead of triggering full refreshes.🧩 Signal-Driven State
Signalacts as the reactive state source with explicit and predictable data flow.🌊 Flow Composition
Built-in reactive flow operators including debounce, throttle, filter, and mapping.📦 Reactive Collections
Native reactive list support with fine-grained index tracking and batch updates.✅ Pure Native C#
Modern C# syntax, nullable reference types, implicit usings, and multi-version .NET compatibility.
Installation
NuGet
Install-Package NeHive.Reactive
dotnet add package NeHive.Reactive
Quick Start
1. Basic Reactivity
using NeHive.Reactive;
using var scope = new Scope();
var count = new MutSignal<int>(0);
scope.CreateEffect(() =>
{
Console.WriteLine(
$"Count: {count.RxValue}");
});
count.RxValue = 1;
count.RxValue = 2;
Output:
Count: 0
Count: 1
Count: 2
2. Computed State
Computed values cache automatically and only update when dependencies change.
using var scope = new Scope();
var price = new MutSignal<double>(100);
var quantity = new MutSignal<int>(2);
var total = new Computed<double>(
() => price.RxValue * quantity.RxValue);
scope.CreateEffect(() =>
{
Console.WriteLine(
$"Total: {total.RxValue}");
});
price.RxValue = 150;
quantity.RxValue = 5;
3. Async Reactive State
AsyncMemo<T> provides reactive async state with loading and error tracking.
using var scope = new Scope();
var userId = new MutSignal<int>(1);
var user = scope.CreateAsyncMemo(async epoch =>
{
var id = epoch.Pull(userId);
await Task.Delay(500);
return $"User-{id}";
});
scope.CreateEffect(() =>
{
Console.WriteLine(
$"Loading: {user.RxLoading}");
Console.WriteLine(
$"Value: {user.RxValue}");
});
userId.RxValue = 2;
4. Reactive Flow
ReactiveFlow provides lightweight stream-style operators.
using var scope = new Scope();
var input = new MutSignal<int>(0);
var effect = scope
.CreateReactiveFlow(input)
.ThrottleLatest(500)
.Filter(v => v > 3)
.Map(v => v * 10)
.PushEffect(v =>
{
Console.WriteLine(
$"Output: {v}");
});
for (var i = 0; i < 10; i++)
{
input.RxValue = i;
await Task.Delay(100);
}
5. Reactive Collections
using var scope = new Scope();
var list = new ListStore<int>(
[1, 2, 3]);
scope.CreateEffect(() =>
{
Console.WriteLine(
$"Count: {list.Count}");
});
scope.CreateEffect(() =>
{
list.TryGetValue(0, out var value);
Console.WriteLine(
$"First: {value}");
});
list.BatchModify(items =>
{
items[0] = 999;
items.Add(4);
});
list.Sort();
list.Reverse();
Core APIs
Runtime Primitives
| API | Description |
|---|---|
Scope |
Reactive lifecycle container |
Signal<T> |
Readonly reactive state |
MutSignal<T> |
Mutable reactive state |
Computed<T> |
Cached computed signal |
Effect |
Reactive side effect |
AsyncMemo<T> |
Async reactive computed value |
Selector<T> |
Key-based selective dependency tracking |
Context<T> |
Scoped dependency/context propagation |
Runtime Utilities
| API | Description |
|---|---|
Rx.Batch() |
Batch signal updates |
Rx.Untrack() |
Read values without dependency tracking |
Rx.OnDispose() |
Register cleanup callbacks |
ReactiveFlow Operators
| API | Description |
|---|---|
Filter() |
Conditional filtering |
Map() |
Value transformation |
Debounce() |
Debounced updates |
ThrottleLatest() |
Throttled latest emission |
PushEffect() |
Terminal effect subscription |
PushComputed() |
Convert flow into computed state |
PushAsyncMemo() |
Convert flow into async reactive state |
Reactive Collections
ListStore<T>
Enhanced reactive list container.
Features:
- Fine-grained index tracking (each index is an independent signal)
BatchModifymerged updates- Native
Add/RemoveAt/Sort/Reverse/Clear - Built-in reactive LINQ-style queries
Use Cases
Declarative cross-platform UI state management
(with NeHive.UI.Avalonia)Lightweight desktop and mobile state-driven applications
Debounced forms, search suggestions, and high-frequency UI interactions
Business workflow orchestration and reactive dependency updates
Fine-grained reactive systems without heavy runtime overhead
Interoperability
SignalObservable<T>
Converts a MutSignal<T> into a standard IObservable<T> sequence.
var signal = new MutSignal<int>(0);
var observable = new SignalObservable<int>(signal);
observable.Subscribe(value => Console.WriteLine(value));
signal.RxValue = 42; // Observer receives 42
Rx.From(IObservable<T>, T)
Converts an external IObservable<T> into a reactive ISignal<T>.
StoreAttribute / NoSignalAttribute / ComputedAttribute
Attribute-based reactive store generation markers.
Interoperability
SignalObservable<T>
Converts a MutSignal<T> into a standard IObservable<T> sequence.
Rx.From(IObservable<T>, T)
Converts an external IObservable<T> into a reactive ISignal<T> with automatic lifecycle management.
Array Diffing
| API | Description |
|---|---|
| ArrayDiffUtil | Compute minimal diffs between two lists |
| ArrayMapResult | Incremental array map with move preservation |
| ArrayMapMemo | Reactive signal for incremental array mapping |
Array Diffing
| API | Description |
|---|---|
| ArrayDiffUtil | Compute minimal diffs between two lists |
| ArrayMapResult | Incremental array map with move preservation |
| ArrayMapMemo | Reactive signal for incremental array mapping |
Inspirations
NeHive.Reactive is heavily inspired by the ideas and research behind:
License
MIT
| Product | Versions 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 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. |
-
net10.0
- NeHive.Model (>= 0.1.0)
-
net7.0
- NeHive.Model (>= 0.1.0)
-
net8.0
- NeHive.Model (>= 0.1.0)
-
net9.0
- NeHive.Model (>= 0.1.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on NeHive.Reactive:
| Package | Downloads |
|---|---|
|
NeHive.UI.Avalonia
UI integration layer for NeHive runtime model on Avalonia |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.1 | 128 | 6/9/2026 |