A compact, allocation-conscious reactive programming library for .NET built on IObservable<T>. It covers the common Rx operators, scheduling and state without a runtime dependency on System.Reactive, and is designed for trimming and native AOT.
Repo reactiveui/Primitives, read from GitHub 13 min ago. reactiveui has not joined Take My Repo.
reactiveui/Primitives is a public repo on GitHub by reactiveui. A compact, allocation-conscious reactive programming library for .NET built on IObservable<T>. It covers the common Rx operators, scheduling and state without a runtime dependency on System.Reactive, and is designed for trimming and native AOT. It declares the MIT license on GitHub. It is written mainly in C#, has 16 stars and last changed on 2026-11-21. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-22.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
ReactiveUI.Primitives is a small, fast library for values that arrive over time. A button click, a timer tick and a
network reply are all values that arrive over time. You subscribe to a source, and the source pushes each value to you
as it happens. The library builds on IObservable<T> and IObserver<T>, two interfaces that .NET already ships, so you
keep the types your code already uses. It adds no runtime reflection and generates no code at run time, so it works
under ahead-of-time compilation.
Full documentation lives at reactiveui.net/documentation/primitives. This readme covers the whole surface in brief; the site carries the detailed guides, per-operator pages and runnable samples.
You have a search box. You want to run a search when the user stops typing. You do not want to search on every keystroke, and you do not want to search a single letter.
C# gives you an event for the typing. The rest you write yourself:
// Search when the user stops typing for 300ms.
private System.Timers.Timer? _timer;
private void OnTextChanged(object? sender, EventArgs e)
{
var text = box.Text;
if (text.Length <= 2)
{
return;
}
// Cancel the search we were about to run, start the wait again,
// and capture the text so the timer sees the value the user typed last.
_timer?.Stop();
_timer?.Dispose();
_timer = new System.Timers.Timer(300) { AutoReset = false };
_timer.Elapsed += (_, _) => RunSearch(text);
_timer.Start();
}
// Then detach the handler and dispose the timer when the view goes away.
With this library, you write the same rules as a chain:
using var search = Signal.FromEventPattern(
handler => box.TextChanged += handler,
handler => box.TextChanged -= handler)
.Map(_ => box.Text)
.Keep(text => text.Length > 2)
.Throttle(TimeSpan.FromMilliseconds(300))
.Subscribe(text => RunSearch(text));
Each line does one job. FromEventPattern turns the event into a source. Map turns each value into another value.
Keep drops the values you do not want. Throttle waits for a quiet period after the most recent value. Subscribe
runs your code on what is left.
Subscribe hands back an IDisposable. Disposing it detaches the event handler and cancels the pending wait. That is
the whole cleanup.
[!NOTE]
Throttletimes the wait on the thread pool. It does not move the value to the UI thread. Pass a sequencer toThrottle, or addObserveOn, when the subscriber needs the UI thread.
1. Install the package.
dotnet add package ReactiveUI.Primitives
2. Create a signal. A Signal<T> is a source you can push values into. It is also a source you can subscribe to.
using ReactiveUI.Primitives;
using ReactiveUI.Primitives.Signals;
var signal = new Signal<int>();
3. Subscribe. You give Subscribe up to three callbacks. The first takes each value. The second takes an error.
The third runs when the signal finishes.
using IDisposable subscription = signal.Subscribe(
value => Console.WriteLine($"next: {value}"),
error => Console.WriteLine($"error: {error.Message}"),
() => Console.WriteLine("completed"));
4. Push values. OnNext sends a value to every current subscriber. Each call reaches your first callback right
away.
signal.OnNext(1); // prints next: 1
signal.OnNext(2); // prints next: 2
5. Finish the signal. OnCompleted ends it successfully. OnError ends it with an exception. A signal that ends
sends nothing more.
signal.OnCompleted(); // prints completed
6. Dispose the subscription. Disposing unsubscribes you. The using on step 3 does this at the end of the block.
A subscription you never dispose keeps your callbacks alive.
subscription.Dispose();
Collect several subscriptions in a MultipleDisposable and dispose them together:
using ReactiveUI.Primitives.Disposables;
var subscriptions = new MultipleDisposable();
signal.Subscribe(value => Console.WriteLine(value)).DisposeWith(subscriptions);
signal.Subscribe(value => Console.WriteLine(value * 10)).DisposeWith(subscriptions);
subscriptions.Dispose();
IObservable<T> is a source. You call Subscribe on it. It pushes values to you.
IObserver<T> is a subscriber. It has three methods. The source calls OnNext for each value, OnError once if
something fails, and OnCompleted once when there is nothing more. OnError and OnCompleted both end the source. The
source calls one of them, once. It sends no values after that.
A Signal<T> is both. It implements ISignal<T>, which combines IObserver<T>, IObservable<T> and IsDisposed.
So you push values into one end and subscribe at the other. HasObservers tells you whether anyone is subscribed.
IsDisposed tells you whether the signal is disposed.
A witness is a lightweight observer wrapper. The library builds one for you when you pass callbacks to Subscribe.
You rarely write one by hand. Pass delegates or an IObserver<T> instead.
Subscribing hands you an IDisposable. Dispose it to unsubscribe. Scheduled work hands you one too. Dispose that to
cancel the work. DisposeWith adds a disposable to a MultipleDisposable so you can dispose a group in one call.
[!NOTE] Another package can pull in System.Reactive, which declares its own
Subscribeextension methods forIObservable<T>. Both sets are then in scope and the call is ambiguous. See Using both libraries in one project for the fixes.
Every package ships on NuGet.org at the same version. Start with the base package:
dotnet add package ReactiveUI.Primitives
Then import the namespaces you need:
using ReactiveUI.Primitives;
using ReactiveUI.Primitives.Signals;
using ReactiveUI.Primitives.Disposables;
using ReactiveUI.Primitives.Concurrency;
using ReactiveUI.Primitives.Extensions;
Each package covers one integration point. Take the ones you need.
| Package | NuGet | Use when |
|---|---|---|
| ReactiveUI.Disposables | You want only the disposable types, such as Disposable, MultipleDisposable, Slot or Pocket. |
|
| ReactiveUI.Primitives.Core | The shared core behind the lean and System.Reactive packages. You usually get it as a dependency. | |
| ReactiveUI.Primitives | The default package: signals, operators, sequencers and the extension helpers. | |
| ReactiveUI.Primitives.Reactive | You want the same API compiled against System.Reactive Unit and IScheduler. |
|
| ReactiveUI.Primitives.Async.Core | The shared core behind the async packages. | |
| ReactiveUI.Primitives.Async | You want native IObservableAsync<T> and IObserverAsync<T> signals. |
|
| ReactiveUI.Primitives.Async.Reactive | You want the async API compiled against System.Reactive Unit and IScheduler. |
|
| ReactiveUI.Primitives.ObservableEvents | You want .NET events exposed as IObservable<T> properties. This package is an analyzer. |
|
| ReactiveUI.Primitives.R3Bridge.Generator | You want generated R3 and R3Async bridge adapters. This package is an analyzer. | |
| ReactiveUI.Primitives.Wpf | You want the WPF dispatcher as a sequencer. | |
| ReactiveUI.Primitives.Wpf.Reactive | You want the WPF dispatcher as a System.Reactive scheduler. | |
| ReactiveUI.Primitives.WinForms | You want a Windows Forms control as a sequencer. | |
| ReactiveUI.Primitives.WinForms.Reactive | You want a Windows Forms control as a System.Reactive scheduler. | |
| ReactiveUI.Primitives.WinUI | You want the WinUI dispatcher queue as a sequencer. | |
| ReactiveUI.Primitives.WinUI.Reactive | You want the WinUI dispatcher queue as a System.Reactive scheduler. | |
| ReactiveUI.Primitives.Uno | You want an Uno Platform dispatcher queue as a sequencer. | |
| ReactiveUI.Primitives.Uno.Reactive | You want an Uno Platform dispatcher queue as a System.Reactive scheduler. | |
| ReactiveUI.Primitives.Blazor | You want the Blazor renderer as a sequencer. | |
| ReactiveUI.Primitives.Blazor.Reactive | You want the Blazor renderer as a System.Reactive scheduler. | |
| ReactiveUI.Primitives.Avalonia | You want the Avalonia UI thread as a sequencer. | |
| ReactiveUI.Primitives.Avalonia.Reactive | You want the Avalonia UI thread as a System.Reactive scheduler. | |
| ReactiveUI.Primitives.Maui | You want the MAUI dispatcher as a sequencer. | |
| ReactiveUI.Primitives.Maui.Reactive | You want the MAUI dispatcher as a System.Reactive scheduler. |
A sequencer decides when and on which thread work runs. ISequencer is this library's own scheduling contract.
The R3 and R3Async bridge lives in its own analyzer package:
dotnet add package ReactiveUI.Primitives.R3Bridge.Generator
That generator adds no runtime dependency. It writes bridge code only when your project already references the R3 or R3Async types.
A target framework (TFM) is the .NET version and platform a build targets, such as net10.0. Most packages share one
list: net10.0, net11.0, net47, net471, net472, net48 and net481. The repository calls that list
$(LibraryTargetFrameworks) and sets it in src/Directory.Build.props.
| Package | Target frameworks |
|---|---|
ReactiveUI.Disposables, ReactiveUI.Primitives.Core, ReactiveUI.Primitives.Async.Core, ReactiveUI.Primitives.Async, ReactiveUI.Primitives.Async.Reactive |
The shared list above. |
ReactiveUI.Primitives, ReactiveUI.Primitives.Reactive |
The shared list, plus net10.0-android and net11.0-android, plus the Apple TFMs net10.0-ios, net11.0-ios, net10.0-tvos, net11.0-tvos, net10.0-macos, net11.0-macos, net10.0-maccatalyst and net11.0-maccatalyst. The mobile and Apple TFMs build on Windows or macOS. |
ReactiveUI.Primitives.Wpf, ReactiveUI.Primitives.Wpf.Reactive, ReactiveUI.Primitives.WinForms, ReactiveUI.Primitives.WinForms.Reactive |
net10.0-windows, net11.0-windows, net47, net471, net472, net48, net481. |
ReactiveUI.Primitives.WinUI, ReactiveUI.Primitives.WinUI.Reactive |
net10.0-windows10.0.19041.0, net11.0-windows10.0.19041.0. |
ReactiveUI.Primitives.Blazor, ReactiveUI.Primitives.Blazor.Reactive, ReactiveUI.Primitives.Avalonia, ReactiveUI.Primitives.Avalonia.Reactive |
net10.0, net11.0. |
ReactiveUI.Primitives.Maui, ReactiveUI.Primitives.Maui.Reactive |
net10.0, net11.0. |
ReactiveUI.Primitives.ObservableEvents, ReactiveUI.Primitives.R3Bridge.Generator |
netstandard2.0. |
The dependency list is short by design. ReactiveUI.Primitives references ReactiveUI.Disposables and
ReactiveUI.Primitives.Core. .Reactive packages reference System.Reactive. The .NET Framework TFMs pull in
support packages such as System.ValueTuple, Microsoft.Bcl.TimeProvider, System.Threading.Channels,
System.Runtime.CompilerServices.Unsafe, System.ComponentModel.Annotations, System.Buffers, System.Memory and
System.Collections.Immutable.
The platform packages reference their platform. Blazor references Microsoft.AspNetCore.Components. Avalonia references
Avalonia. MAUI references Microsoft.Maui.Core and the Microsoft.Extensions packages it needs. WinUI references
Microsoft.WindowsAppSDK.
A signal is a stream of values you can subscribe to. A signal hands you values one at a time. It ends in one of two
ways: it completes, or it fails with an error. When you subscribe you get back an IDisposable. Dispose it to stop
listening.
A sequencer decides which thread runs your code. You pass one to an operator when you care where the work lands.
A hub is an object that takes values in and hands them to every subscriber.
Most operators have a short name and a second name. Both names run the same code, so pick the one you like and use it everywhere. The last column of each table gives you the matching name from the libraries you may know.
RxVoid is this library's stand-in for "a value that carries no information".
These build a signal from something else: a number range, a collection, a task, an event, or your own code. Unless a
row says otherwise, the method is static on Signal.
| Operator | What it does | LINQ / System.Reactive name |
|---|---|---|
Signal.Emit(value) |
Emits one value, then completes. | Observable.Return |
Signal.Emit(value, sequencer) |
Emits one value on the sequencer you name. | Return(value, scheduler) |
Signal.Emit(RxVoid), Signal.EmitRxVoid() |
Returns a shared signal that emits the unit value. | Return(Unit.Default) |
Signal.Emit(bool) |
Returns one of two cached signals, one for true and one for false. | Return(bool) |
Signal.Emit(int) |
Emits one int, then completes. | Return(int) |
Signal.Return(value), Signal.Return(value, sequencer) |
Another name for Emit. |
Observable.Return |
Signal.None<T>() |
Completes at once and emits nothing. | Observable.Empty |
Signal.None<T>(sequencer) |
Completes on the sequencer and emits nothing. | Empty(scheduler) |
Signal.None<T>(witness), Signal.None<T>(sequencer, witness) |
Completes with no values and reads the element type from an unused argument. | Empty<T>() |
Signal.Empty<T>(), Signal.Empty<T>(sequencer) |
Another name for None. |
Observable.Empty |
Signal.Silent<T>(), Signal.Silent<T>(witness) |
Emits nothing and never ends. | Observable.Never |
Signal.Never<T>() |
Another name for Silent. |
Observable.Never |
Signal.Fail<T>(error) |
Fails with your error as soon as someone subscribes. | Observable.Throw |
Signal.Fail<T>(error, sequencer) |
Fails on the sequencer you name. | Throw(e, scheduler) |
Signal.Fail<T>(error, witness), Signal.Fail<T>(error, sequencer, witness) |
Fails and reads the element type from an unused argument. | Throw<T>(e) |
Signal.Throw<T>(error), Signal.Throw<T>(error, sequencer) |
Another name for Fail. |
Observable.Throw |
Signal.Loop(value) |
Emits one value over and over and never ends. | Observable.Repeat(value) |
Signal.Loop(value, count) |
Emits one value count times, then completes. |
Repeat(value, count) |
Signal.Repeat(value), Signal.Repeat(value, repeatCount) |
Another name for Loop. |
Observable.Repeat |
Signal.Sequence(start, count) |
Emits count whole numbers in a row, then completes. |
Observable.Range |
Signal.Sequence(start, count, sequencer) |
Emits the same numbers on the sequencer you name. | Range(..., scheduler) |
Signal.Range(start, count), Signal.Range(start, count, sequencer) |
Another name for Sequence. |
Observable.Range |
Signal.Unfold(initialState, condition, iterate, resultSelector) |
Steps a state value forward and emits a projection of each step while the condition holds. | Observable.Generate |
Signal.Iterate(initialState, condition, iterator, resultSelector) |
Another name for Unfold. |
Generate |
Signal.Generate(initialState, condition, iterate, resultSelector) |
A third name for Unfold. |
Observable.Generate |
Signal.Create<T>(subscribe) |
Builds a signal from your own subscribe function and keeps the subscription alive when a subscriber's OnNext throws. |
Observable.Create |
Signal.Create<T>(subscribe, isRequiredSubscribeOnCurrentThread) |
Builds the same signal and states that subscription must go through the current-thread sequencer. | Observable.Create |
Signal.Create<T>(async subscribe), Signal.Create<T>(async subscribe with token) |
Builds a signal from an async subscribe function. | Observable.Create (async) |
Signal.CreateSafe<T>(subscribe), Signal.CreateSafe<T>(subscribe, isRequiredSubscribeOnCurrentThread) |
Builds a signal that releases the subscription when a subscriber's OnNext throws. |
Observable.Create |
Signal.CreateWithState<T, TState>(state, subscribe) |
Builds a signal and threads a state object through, so your callback can be static and allocate nothing. |
- |
Signal.CreateWithState<T, TState>(state, subscribe, isRequiredSubscribeOnCurrentThread) |
Does the same with the current-thread flag. | - |
Signal.Lazy<T>(observableFactory) |
Calls your factory once per subscriber, so each one gets a fresh source. | Observable.Defer |
Signal.Defer<T>(observableFactory) |
Another name for Lazy. |
Observable.Defer |
Signal.Defer<T>(async observableFactory), Signal.Defer<T>(async observableFactory with token) |
Builds the source asynchronously for each subscriber. | Observable.Defer (async) |
Signal.If<T>(condition, thenSource) |
Picks your source or an empty one for each subscriber. | Observable.If |
Signal.If<T>(condition, thenSource, elseSource) |
Picks one of two sources for each subscriber. | Observable.If |
Signal.Case<TKey, T>(selector, sources) |
Picks a source out of a dictionary by key for each subscriber, and uses an empty one when the key is missing. | Observable.Case |
Signal.Case<TKey, T>(selector, sources, defaultSource) |
Picks a source by key and falls back to the one you name. | Observable.Case |
Signal.Use<TResource, T>(resourceFactory, signalFactory) |
Ties a resource to the subscription and disposes it when the subscription ends. | Observable.Using |
Signal.Using<TResource, T>(resourceFactory, observableFactory) |
Another name for Use. |
Observable.Using |
Signal.FromEnumerable<T>(values) |
Emits each item of a collection in order, then completes. | ToObservable() |
Signal.FromEnumerable<T>(values, cancellationToken) |
Emits the same items and stops when the token fires. | ToObservable() |
Signal.FromAsyncEnumerable<T>(values), Signal.FromAsyncEnumerable<T>(values, cancellationToken) |
Emits each item of an async stream. | ToObservable() |
Signal.FromTask<T>(task) |
Emits the task's result, then completes. | task.ToObservable() |
Signal.FromAsync<T>(taskFactory) |
Starts a task for each subscriber and emits its result. | Observable.FromAsync |
Signal.FromAsync<T>(taskFactory with token) |
Starts a task whose token cancels when you dispose the subscription. | Observable.FromAsync |
Signal.FromAsync<T>(taskFactory with token, cancellationToken) |
Starts a task and watches a token you supply. | Observable.FromAsync |
Signal.FromTask(execution) |
Returns an ITaskSignal<RxVoid> and hands your work a cancellation source that disposal cancels. |
- |
Signal.FromTask(execution, sequencer), Signal.FromTask(execution, sequencer, cts) |
Does the same on a sequencer, or with a cancellation source you own. | - |
Signal.FromTask<TResult>(actionAsync) and its sequencer and cts overloads |
Does the same for work that returns a value. | - |
Signal.FromEvent<TEventArgs>(addHandler, removeHandler) |
Turns an add and remove callback pair into a signal of the event's argument. | Observable.FromEvent |
Signal.FromEvent<TEventHandler, TEventArgs>(conversion, addHandler, removeHandler) |
Does the same when the event uses its own delegate type. | Observable.FromEvent |
Signal.FromEvent<TEventHandler, TEventArgs>(conversion, addHandler, removeHandler, sequencer) |
Attaches and detaches the handler on a sequencer. | Observable.FromEvent |
Signal.FromEventPattern(addHandler, removeHandler), and the sequencer overload |
Turns a plain EventHandler event into a signal of EventPattern<EventArgs>. |
Observable.FromEventPattern |
Signal.FromEventPattern<TEventArgs>(addHandler, removeHandler), and the sequencer overload |
Does the same for an EventHandler<TEventArgs> event. |
FromEventPattern |
Signal.FromEventPattern<TEventHandler, TEventArgs>(addHandler, removeHandler), and the sequencer overload |
Does the same for an event with its own delegate type. | FromEventPattern |
Signal.FromEventPattern<TEventHandler, TEventArgs>(conversion, addHandler, removeHandler), and the sequencer overload |
Does the same and takes an explicit conversion. | FromEventPattern |
Signal.FromEventPattern<TEventHandler, TSender, TEventArgs>(conversion, addHandler, removeHandler), and the sequencer overload |
Does the same and keeps the sender's type. | FromEventPattern |
Signal.Start(action), Signal.Start(action, sequencer) |
Runs an action on a sequencer and emits the unit value when it finishes. | Observable.Start |
Signal.Start<T>(function), Signal.Start<T>(function, sequencer) |
Runs a function on a sequencer and emits its result. | Observable.Start |
Signal.After(dueTime), Signal.After(dueTime, sequencer) |
Emits 0L once after the delay, then completes. |
Observable.Timer |
Signal.After(DateTimeOffset), Signal.After(DateTimeOffset, sequencer) |
Emits 0L once at the time you name. |
Timer |
Signal.After(dueTime, period), Signal.After(dueTime, period, sequencer) |
Emits a rising count after the delay, then once per period. | Timer |
Signal.Timer(...), all six overloads |
Another name for After. |
Observable.Timer |
Signal.Every(period), Signal.Every(period, sequencer) |
Emits a rising count once per period, forever. | Observable.Interval |
Signal.Interval(period), Signal.Interval(period, sequencer) |
Another name for Every. |
Observable.Interval |
Signal.Pulse(period), Signal.Pulse(period, sequencer) |
A third name for Every. |
Observable.Interval |
Signal.Blend<T>(params sources) |
Subscribes to every source at once and passes values along as they arrive. | Observable.Merge |
Signal.Merge<T>(params sources), Signal.Merge<T>(IEnumerable sources) |
Another name for Blend. |
Observable.Merge |
Signal.Chain<T>(params sources) |
Runs the sources one after another, each starting when the one before it completes. | Observable.Concat |
Signal.Concat<T>(params sources), Signal.Concat<T>(IEnumerable sources) |
Another name for Chain. |
Observable.Concat |
Signal.Race<T>(params sources) |
Subscribes to every source and keeps the first one to react. | Observable.Amb |
Signal.Switch<T>(sources) |
Follows only the newest inner signal. | Observable.Switch |
Signal.Pair<TLeft, TRight, TResult>(left, right, selector) |
Joins values by position: first with first, second with second. | Observable.Zip |
Signal.SyncLatest<TLeft, TRight, TResult>(left, right, selector) |
Combines the latest value from each side whenever either one fires. | Observable.CombineLatest |
Signal.PairLatest<TLeft, TRight, TResult>(left, right, selector) |
Another name for the static SyncLatest. |
CombineLatest |
Signal.ForkJoin<TLeft, TRight, TResult>(left, right, selector) |
Waits for both sides to complete, then emits one result built from their last values. | Observable.ForkJoin |
Signal.OnErrorResumeNext<T>(first, second), and the params and collection overloads |
Runs the sources in order and ignores an error from any of them. | Observable.OnErrorResumeNext |
Signal.Recover<TSource>(params sources) |
Tries each source in turn and moves to the next one only when a source fails. | Observable.Catch(params) |
Signal.Scheduled<T>(sequencer) |
Creates a hub that delivers its values on a sequencer. | Subject + ObserveOn |
Signal.Scheduled<T>(sequencer, defaultObserver) |
Creates the same hub and names an observer to receive values when nobody else subscribes. | - |
Signal.Serialized<T>(), Signal.Serialized<T>(signal) |
Creates a hub that takes calls from any thread and delivers them one at a time. | Subject.Synchronize |
Signal.Delayable<T>(isDelayed, flushDistinct) |
Creates a hub that holds values back while it is delayed and emits one batch without duplicates when you call Flush(). |
- |
TaskSignal.Create<TResult>(observableFactory), and its sequencer and cts overloads |
Creates a task-backed signal whose source is built from the signal itself. | - |
IEnumerable<T>.ToSignal(), IEnumerable<T>.ToSignal(cancellationToken) |
Turns a collection into a signal that emits each item, then completes. | ToObservable() |
IEnumerable<T>.ToObservable(), and the sequencer and token overloads |
Another name for ToSignal. |
ToObservable() |
Task<T>.ToSignal() |
Turns a task into a signal that emits its result. | ToObservable() |
Task<T>.ToObservable() |
Another name for Task<T>.ToSignal. |
ToObservable() |
Observables.Return<T>(value) |
Emits one value inside the Subscribe call itself. |
Observable.Return(value, ImmediateScheduler) |
Emit gives you a signal with one value in it.
Signal.Emit(42).Subscribe(value => Console.WriteLine(value));
// prints: 42
None completes without giving you a value.
Signal.None<string>().Subscribe(
value => Console.WriteLine(value),
() => Console.WriteLine("done"));
// prints: done
Fail hands every subscriber an error.
Signal.Fail<int>(new InvalidOperationException("no rows"))
.Subscribe(
value => Console.WriteLine(value),
error => Console.WriteLine(error.Message));
// prints: no rows
Sequence counts up from a starting number.
Signal.Sequence(5, 3).Subscribe(number => Console.Write(number + " "));
// prints: 5 6 7
ToSignal turns any collection into a signal.
string[] names = ["ana", "bo", "cy"];
names.ToSignal().Subscribe(name => Console.Write(name + " "));
// prints: ana bo cy
Create lets you push values yourself. Return a disposable that cleans up when the subscriber leaves.
var countdown = Signal.Create<int>(observer =>
{
observer.OnNext(3);
observer.OnNext(2);
observer.OnNext(1);
observer.OnCompleted();
return EmptyDisposable.Instance;
});
countdown.Subscribe(number => Console.Write(number + " "));
// prints: 3 2 1
Lazy builds the source at subscribe time, so each subscriber gets its own.
var stamp = Signal.Lazy(() => Signal.Emit(DateTime.UtcNow));
stamp.Subscribe(time => Console.WriteLine(time));
stamp.Subscribe(time => Console.WriteLine(time));
// prints: two different times, one per subscriber
FromAsync starts a task for each subscriber.
var page = Signal.FromAsync(async token =>
{
using var client = new HttpClient();
return await client.GetStringAsync("https://example.com", token);
});
page.Subscribe(body => Console.WriteLine(body.Length));
// prints: the number of characters in the page
FromEventPattern turns a .NET event into a signal. Each value carries the sender and the event arguments.
Every overload requires TEventArgs to derive from EventArgs, which binds the handler at compile time and keeps the
factory free of reflection. For an argument type that does not derive from EventArgs, use Signal.FromEvent, which
places no constraint on it.
// chat.MessageReceived is an event EventHandler<MessageEventArgs>
Signal.FromEventPattern<MessageEventArgs>(
handler => chat.MessageReceived += handler,
handler => chat.MessageReceived -= handler)
.Subscribe(pattern => Console.WriteLine(pattern.EventArgs.Text));
// prints: the text of each message as it arrives
After fires once, later.
Signal.After(TimeSpan.FromSeconds(2))
.Subscribe(tick => Console.WriteLine("two seconds later"));
// prints: two seconds later
Every fires over and over on a timer.
Signal.Every(TimeSpan.FromSeconds(1))
.Take(3)
.Subscribe(count => Console.Write(count + " "));
// prints: 0 1 2
These change each value into something else.
| Operator | What it does | LINQ / System.Reactive name |
|---|---|---|
Map(selector) |
Runs your function on each value and emits the result. | Select |
MapIndexed(selector) |
Runs your function on each value and its position, counting from zero. | Select (indexed) |
MapWith(state, selector) |
Runs your function on each value and threads a state object through, so your lambda can be static. |
- |
Select(selector) |
Another name for Map. |
Select |
Select(selector with index) |
Another name for MapIndexed. |
Select |
SelectWith(state, selector) |
Another name for MapWith. |
- |
Spark() |
Turns values, errors and completion into Spark<T> records you can read as plain data. |
Materialize |
Materialize() |
Another name for Spark. |
Materialize |
Unspark() |
Turns Spark<T> records back into real values, errors and completion. |
Dematerialize |
Dematerialize() |
Another name for Unspark. |
Dematerialize |
CastTo<TResult>() |
Casts each value to the type you name and fails when one does not fit. | Cast |
Cast<TResult>() |
Another name for CastTo. |
Cast |
Bind(selector) |
Turns each value into an inner signal and passes along everything those signals emit. | SelectMany |
FlatMap(selector) |
Another name for Bind. |
SelectMany |
FlatMap(collectionSelector, resultSelector) |
Flattens the inner signals and pairs each inner value with the value it came from. | SelectMany |
FlatMapValues(selector) |
Turns each value into a plain collection and emits every item. | SelectMany (enumerable) |
SelectMany(selector) |
Another name for FlatMap. |
SelectMany |
SelectMany(other) |
Replaces each value with the same inner signal and merges the results. | SelectMany |
SelectMany(enumerable selector) |
Another name for FlatMapValues. |
SelectMany |
SelectMany(collectionSelector, resultSelector) |
Another name for the two-selector FlatMap. |
SelectMany |
SwitchMap(selector) |
Turns each value into an inner signal and follows only the newest one. | Select(...).Switch() |
SwitchSelect(selector) |
Works like SwitchMap and skips null source values instead of switching away. |
WhereNotNull().Select(...).Switch() |
Choose(chooser) |
Maps and filters in one pass, and emits Value only when HasValue is true. |
Select(...).Where(...) |
SwitchTo() |
Follows only the newest inner signal. | Switch |
Switch() |
Another name for SwitchTo. |
Switch |
Timestamp(), Timestamp(sequencer) |
Attaches the clock's current time to each value as a Moment<T>. |
Timestamp |
TimeInterval(), TimeInterval(sequencer) |
Attaches the gap since the value before it. | TimeInterval |
GroupBy(keySelector) |
Splits the stream into one GroupedSignal<TKey, T> per key. A group arrives when its first value does. |
GroupBy |
GroupBy(keySelector, comparer), GroupBy(keySelector, capacity), GroupBy(keySelector, capacity, comparer) |
Same, with a key comparer, an initial table capacity, or both. | GroupBy |
GroupBy(keySelector, elementSelector) and the same comparer and capacity forms |
Same, and runs elementSelector on each value before it enters its group. |
GroupBy |
GroupByUntil(keySelector, durationSelector) |
Splits the stream into groups that end when their duration signal emits or completes. The next value with that key opens a new group. | GroupByUntil |
GroupByUntil(keySelector, durationSelector, comparer), GroupByUntil(keySelector, durationSelector, capacity), GroupByUntil(keySelector, durationSelector, capacity, comparer) |
Same, with a key comparer, an initial table capacity, or both. | GroupByUntil |
GroupByUntil(keySelector, elementSelector, durationSelector) and the same comparer and capacity forms |
Same, and runs elementSelector on each value before it enters its group. |
GroupByUntil |
Slice(count) |
Hands out one signal per window of count values. The windows do not overlap. |
Window |
Slice(count, skip) |
Opens a window every skip values, so windows can overlap or leave gaps. |
Window |
Slice(timeSpan), Slice(timeSpan, sequencer) |
Hands out one signal per time window. | Window |
Slice(timeSpan, timeShift), Slice(timeSpan, timeShift, sequencer) |
Opens a window of timeSpan every timeShift. |
Window |
Slice(timeSpan, count), Slice(timeSpan, count, sequencer) |
Ends each window after timeSpan or count values, whichever comes first. |
Window |
Slice(boundaries) |
Starts the next window each time the boundary signal emits. | Window |
Slice(closingSelector) |
Ends each window with the signal your selector returns for it. | Window |
Slice(openings, closingSelector) |
Opens a window for each opening value and ends it with the signal your selector returns. | Window |
Window(...) |
Another name for every Slice overload. |
Window |
Buffer hands you a list per window. Slice hands you a signal per window, so you can subscribe to it and work on the
values as they arrive.
Map changes every value.
Signal.Sequence(1, 4)
.Map(number => number * 10)
.Subscribe(value => Console.Write(value + " "));
// prints: 10 20 30 40
MapIndexed gives you the position too.
new[] { "red", "green", "blue" }.ToSignal()
.MapIndexed((colour, index) => $"{index}:{colour}")
.Subscribe(line => Console.Write(line + " "));
// prints: 0:red 1:green 2:blue
FlatMap turns one value into many.
new[] { 1, 2 }.ToSignal()
.FlatMap(number => new[] { number, number * 100 }.ToSignal())
.Subscribe(value => Console.Write(value + " "));
// prints: 1 100 2 200
SwitchMap drops the old inner signal as soon as a new value arrives. Use it for searches and lookups.
searchTerms
.SwitchMap(term => SearchAsync(term).ToSignal())
.Subscribe(results => Console.WriteLine(results.Count));
// prints: results for the newest term only; older searches are dropped
SwitchTo does the same when you hold a signal of signals.
var pages = new[] { Signal.Sequence(1, 2), Signal.Sequence(10, 2) }.ToSignal();
pages.SwitchTo().Subscribe(value => Console.Write(value + " "));
// prints: 1 2 10 11
GroupBy gives each key its own signal. The Key property tells you which group you hold.
Signal.Sequence(1, 6)
.GroupBy(number => number % 2)
.Subscribe(group => group.Subscribe(number => Console.Write($"{group.Key}:{number} ")));
// prints: 1:1 0:2 1:3 0:4 1:5 0:6
Subscribe to a group as soon as it arrives. A group signal sends only the values that come after you subscribe. The source stays subscribed until you dispose the outer subscription and every group subscription.
Slice gives each window its own signal.
Signal.Sequence(1, 5)
.Slice(2)
.Subscribe(window => window.Subscribe(
number => Console.Write(number + " "),
() => Console.Write("| ")));
// prints: 1 2 | 3 4 | 5 |
These decide which values get through.
| Operator | What it does | LINQ / System.Reactive name |
|---|---|---|
Keep(predicate) |
Passes along only the values your test accepts. | Where |
KeepWith(state, predicate) |
Works like Keep and threads a state object through, so your test can be static. |
- |
Where(predicate) |
Another name for Keep. |
Where |
WhereWith(state, predicate) |
Another name for KeepWith. |
- |
KeepNotNull() |
Drops nulls and hands back a stream that cannot be null. | Where(x => x != null) |
WhereNotNull() |
Another name for KeepNotNull. |
WhereNotNull |
KeepType<TResult>() |
Keeps only the values of the type you name. | OfType |
OfType<TResult>() |
Another name for KeepType. |
OfType |
Take(count) |
Emits at most count values, then completes. |
Take |
Skip(count) |
Drops the first count values. |
Skip |
TakeWhile(predicate) |
Emits values while your test holds, then completes. | TakeWhile |
SkipWhile(predicate) |
Drops the leading values while your test holds, then passes the rest along. | SkipWhile |
TakeUntil(other) |
Passes values along until other emits anything; other completing does not stop it. |
TakeUntil |
TakeUntil(cancellationToken) |
Passes values along until the token cancels, then completes. | TakeUntil |
Distinct(), Distinct(comparer) |
Drops a value you have seen anywhere earlier in the stream. | Distinct |
DistinctBy(keySelector), DistinctBy(keySelector, comparer) |
Keeps only the first value for each key. | DistinctBy |
Unique(), Unique(comparer) |
Drops a value only when it matches the one right before it. | DistinctUntilChanged |
UniqueBy(keySelector), UniqueBy(keySelector, comparer) |
Drops a value when its key matches the key right before it. | DistinctUntilChangedBy |
DistinctUntilChanged(), DistinctUntilChanged(comparer) |
Another name for Unique. |
DistinctUntilChanged |
DistinctUntilChangedBy(keySelector), DistinctUntilChangedBy(keySelector, comparer) |
Another name for UniqueBy. |
DistinctUntilChangedBy |
IgnoreValues() |
Drops every value and passes along only completion or an error. | IgnoreElements |
IgnoreElements() |
Another name for IgnoreValues. |
IgnoreElements |
DefaultIfEmpty() |
Emits default when the source completes without a value. |
DefaultIfEmpty |
DefaultIfEmpty(defaultValue) |
Emits your fallback when the source completes without a value. | DefaultIfEmpty |
Keep passes along the values your test accepts.
Signal.Sequence(1, 6)
.Keep(number => number % 2 == 0)
.Subscribe(value => Console.Write(value + " "));
// prints: 2 4 6
KeepNotNull removes nulls and fixes the type for you.
new string?[] { "a", null, "b" }.ToSignal()
.KeepNotNull()
.Subscribe(text => Console.Write(text + " "));
// prints: a b
Take stops after a set number of values.
Signal.Sequence(1, 100)
.Take(3)
.Subscribe(value => Console.Write(value + " "));
// prints: 1 2 3
TakeUntil stops on a token or another signal.
using var cancel = new CancellationTokenSource(TimeSpan.FromSeconds(4));
Signal.Every(TimeSpan.FromSeconds(1))
.TakeUntil(cancel.Token)
.Subscribe(count => Console.Write(count + " "));
// prints: 0 1 2 then completes
Unique drops repeats that sit next to each other.
new[] { 1, 1, 2, 2, 1 }.ToSignal()
.Unique()
.Subscribe(value => Console.Write(value + " "));
// prints: 1 2 1
These put two or more signals together.
| Operator | What it does | LINQ / System.Reactive name |
|---|---|---|
Lead(value) |
Emits one value before the source's own values. | StartWith / Prepend |
Prepend(value) |
Another name for Lead. |
Prepend |
Prepend(params values), Prepend(IEnumerable values) |
Emits several values before the source's own values. | Prepend |
StartWith(params values), StartWith(IEnumerable values) |
Another name for the multi-value Prepend. |
StartWith |
Append(value) |
Emits one extra value after the source completes. | Append |
Chain(second) |
Runs second after this signal completes. |
Concat |
Concat(second) |
Another name for Chain. |
Concat |
Chain() on a signal of signals |
Runs the inner signals one at a time, in the order they arrive. | Concat |
Concat() on a signal of signals |
Another name for the row above. | Concat |
Chain() on a signal of tasks |
Awaits each task in order and emits its result. | Concat |
Concat() on a signal of tasks |
Another name for the row above. | Concat |
Blend() on a signal of signals |
Subscribes to every inner signal at once and passes values along as they arrive. | Merge |
Merge() on a signal of signals |
Another name for Blend. |
Merge |
Merge(second) |
Runs this signal and one other at the same time. | Merge |
Blend() on a collection of signals |
Runs a whole collection of signals at the same time. | Merge |
Blend(maxConcurrent) on a collection of signals |
Runs the same collection with a cap on how many run at once. | Merge(maxConcurrent) |
Merge(), Merge(maxConcurrent) on a collection of signals |
Another name for the two rows above. | Merge |
LinqExtensions.BlendUnique(params sources), LinqExtensions.BlendUnique(sources, comparer) |
Merges the sources and drops a value that matches the one passed along before it. | Merge().DistinctUntilChanged() |
Race() on a signal of signals |
Keeps the inner signal that reacts first and drops the rest. | Amb |
Amb() on a signal of signals |
Another name for Race. |
Amb |
Pair(right, selector) |
Joins values by position: first with first, second with second. | Zip |
Zip(right, selector) |
Another name for Pair. |
Zip |
SyncLatest(right, selector) |
Combines the latest value from each side whenever either one fires, once both have produced a value. | CombineLatest |
PairLatest(right, selector) |
Another name for the two-source SyncLatest. |
CombineLatest |
FuseLatest(right, selector) |
A third name for the two-source SyncLatest. |
CombineLatest |
CombineLatest(right, selector) |
A fourth name for the two-source SyncLatest. |
CombineLatest |
SyncLatest(...) for 3 to 16 sources, 14 overloads |
Combines the latest value from 3 to 16 signals through your selector. | CombineLatest |
CombineLatest(...) for 3 to 16 sources, 14 overloads |
Another name for the row above. | CombineLatest |
CombineLatest(source2) through CombineLatest(source2, ..., source16), 15 overloads |
Combines the latest values and hands you a named tuple, so you write no selector. | CombineLatest (tuple) |
CombineLatest() on a collection of signals |
Combines a collection of same-typed signals into one list per notification. | CombineLatest |
CombineLatest(resultSelector) on a collection of signals |
Does the same and runs your function on the list. | CombineLatest |
LinqExtensions.CombineLatest(new[] { a, b }) |
Array form of the collection combine. Pass an array: listing the sources one by one binds to the tuple overload and gives you a tuple, not a list. | CombineLatest |
Latch(right, selector) |
Emits once per left value and attaches whatever the right side produced last. | WithLatestFrom |
WithLatestFrom(right, selector) |
Another name for Latch. |
WithLatestFrom |
ForkJoin(right, selector) |
Waits for both sides to complete, then emits one result from their final values. | ForkJoin |
Lead puts a starting value in front.
Signal.Sequence(2, 2)
.Lead(0)
.Subscribe(value => Console.Write(value + " "));
// prints: 0 2 3
Append adds a value at the end.
Signal.Sequence(1, 2)
.Append(99)
.Subscribe(value => Console.Write(value + " "));
// prints: 1 2 99
Chain runs the second signal after the first one finishes.
Signal.Sequence(1, 2)
.Chain(Signal.Sequence(10, 2))
.Subscribe(value => Console.Write(value + " "));
// prints: 1 2 10 11
Blend runs signals at the same time and passes values along as they arrive.
var fast = Signal.Every(TimeSpan.FromMilliseconds(100)).Map(_ => "fast");
var slow = Signal.Every(TimeSpan.FromMilliseconds(250)).Map(_ => "slow");
Signal.Blend(fast, slow).Take(4).Subscribe(label => Console.Write(label + " "));
// prints: fast fast slow fast
Pair lines values up by position.
new[] { "a", "b" }.ToSignal()
.Pair(Signal.Sequence(1, 2), (letter, number) => letter + number)
.Subscribe(text => Console.Write(text + " "));
// prints: a1 b2
SyncLatest fires whenever either side changes, using the newest value from both.
var names = new[] { "ana" }.ToSignal();
var ages = new[] { 30, 31 }.ToSignal();
names.SyncLatest(ages, (who, years) => $"{who} is {years}")
.Subscribe(line => Console.WriteLine(line));
// prints: ana is 30
// ana is 31
Latch fires only on the left side and reads the right side's newest value.
var clicks = Signal.Every(TimeSpan.FromSeconds(1));
var temperatures = Signal.Every(TimeSpan.FromMilliseconds(200)).Map(tick => 20 + tick);
clicks.Latch(temperatures, (_, reading) => reading)
.Take(2)
.Subscribe(reading => Console.WriteLine(reading));
// prints: the newest temperature at each click
These change when values arrive.
| Operator | What it does | LINQ / System.Reactive name |
|---|---|---|
Shift(dueTime), Shift(dueTime, sequencer) |
Holds every notification back by a fixed delay. | Delay |
Delay(dueTime), Delay(dueTime, sequencer) |
Another name for Shift. |
Delay |
Delay(DateTimeOffset), Delay(DateTimeOffset, sequencer) |
Holds notifications until the time you name. | Delay |
DelayStart(dueTime), DelayStart(dueTime, sequencer) |
Waits before it subscribes to the source at all. | DelaySubscription |
DelaySubscription(dueTime), DelaySubscription(dueTime, sequencer) |
Another name for DelayStart. |
DelaySubscription |
DelaySubscription(DateTimeOffset), DelaySubscription(DateTimeOffset, sequencer) |
Subscribes at the time you name. | DelaySubscription |
Calm(dueTime), Calm(dueTime, sequencer) |
Emits a value once nothing newer has arrived for the quiet period. | Throttle |
Stabilize(dueTime), Stabilize(dueTime, sequencer) |
Another name for Calm. |
Throttle |
Throttle(dueTime), Throttle(dueTime, sequencer) |
A third name for Calm. |
Throttle |
EmitIfQuiet(dueTime), EmitIfQuiet(dueTime, sequencer) |
Works like Calm and hands back the source unchanged when dueTime is zero or less. |
Throttle |
Probe(period), Probe(period, sequencer) |
Emits the latest value once the period has passed since the value that started the timer. A quiet source sends nothing, and a steady source drifts away from a fixed schedule. A value still waiting when the source completes is sent before the completion. | Sample |
Sample(interval), Sample(interval, sequencer) |
Another name for Probe. |
Sample |
Buffer(timeSpan), Buffer(timeSpan, sequencer) |
Gathers values into one batch per time window. | Buffer |
Buffer(count) |
Gathers values into batches of a fixed size that do not overlap. | Buffer |
Buffer(count, skip) |
Opens a fixed-size batch every skip values, so batches can overlap. |
Buffer |
Collect(timeSpan), Collect(timeSpan, sequencer) |
Another name for the time-window Buffer. |
Buffer(TimeSpan) |
Expire(dueTime), Expire(dueTime, sequencer) |
Fails with TimeoutException when no value arrives within the time you give. Each value restarts the clock, so a busy source never fails. |
Timeout |
Signal.Expire(source, dueTime), Signal.Expire(source, dueTime, sequencer) |
Static form of Expire. |
Timeout |
Timeout(dueTime) and its sequencer overload |
Another name for Expire. Each value restarts the clock. |
Timeout |
Timeout(DateTimeOffset) and its sequencer overload |
Fails with TimeoutException if the sequence has not finished by that moment, whatever values arrive first. |
Timeout |
Signal.Timeout(source, dueTime), Signal.Timeout(source, dueTime, sequencer) |
Static form of Timeout. |
Timeout |
Shift moves everything later by a fixed amount.
Signal.Emit("late")
.Shift(TimeSpan.FromSeconds(1))
.Subscribe(text => Console.WriteLine(text));
// prints: late, one second after you subscribe
Calm waits for quiet. Use it on a text box so you search once the typing stops.
keystrokes
.Calm(TimeSpan.FromMilliseconds(300))
.Subscribe(term => Console.WriteLine(term));
// prints: the search term once the user stops typing for 300 milliseconds
Probe takes the newest value on a schedule and ignores the rest.
Signal.Every(TimeSpan.FromMilliseconds(100))
.Probe(TimeSpan.FromMilliseconds(500))
.Take(2)
.Subscribe(count => Console.Write(count + " "));
// prints: 4 9
Buffer gathers values into batches.
Signal.Sequence(1, 7)
.Buffer(3)
.Subscribe(batch => Console.Write($"[{string.Join(",", batch)}] "));
// prints: [1,2,3] [4,5,6] [7]
Expire fails when the source takes too long.
slowRequest
.Expire(TimeSpan.FromSeconds(5))
.Subscribe(
result => Console.WriteLine(result),
error => Console.WriteLine(error.GetType().Name));
// prints: TimeoutException when the request takes more than 5 seconds
These decide what happens when a signal fails.
| Operator | What it does | LINQ / System.Reactive name |
|---|---|---|
Recover(handler) |
Switches to the replacement signal your handler builds when an error arrives. | Catch |
Rescue(handler) |
Another name for Recover. |
Catch |
Recover<TException>(handler) |
Handles only the one exception type you name. | Catch<TException> |
Catch<TException>(handler) |
Another name for the typed Recover. |
Catch |
Recover() on a collection of signals |
Tries each source in turn until one finishes without an error. | Catch(params) |
Resume(fallback) |
Carries on with your fallback signal after an error. | OnErrorResumeNext |
OnErrorResumeNext(second) |
Carries on with second when this signal completes or fails. Unlike Resume, it also moves on after a clean completion. |
OnErrorResumeNext |
Reattempt(retryCount) |
Subscribes again after an error, up to the number of extra tries you allow, then passes the last error along. The count is extra tries, so Reattempt(2) subscribes three times. |
Retry |
Retry(retryCount) |
Runs the source up to that many times in total, stopping at the first run that ends without an error. Retry(3) runs it three times. |
Retry |
Repeat() |
Subscribes again each time the source completes, forever. | Repeat |
Repeat(repeatCount) |
Runs the source the number of times you name in total, starting each run when the one before it completes. Repeat(3) runs it three times, not four. |
Repeat |
Finally(finallyAction) |
Runs your cleanup action once when the subscription ends, whatever ends it. | Finally |
OnCleanup(finallyAction) |
Another name for Finally. |
Finally |
Exception.Throw() |
Throws the exception and keeps its stack trace on older frameworks. | - |
Exception?.Rethrow() |
Throws the exception when there is one, and does nothing when it is null. | - |
Recover swaps in another signal when something fails.
Signal.Fail<string>(new HttpRequestException("offline"))
.Recover(error => Signal.Emit("cached value"))
.Subscribe(text => Console.WriteLine(text));
// prints: cached value
Resume carries straight on with a fallback.
Signal.Fail<int>(new InvalidOperationException())
.Resume(Signal.Sequence(1, 2))
.Subscribe(value => Console.Write(value + " "));
// prints: 1 2
Reattempt tries the whole source again.
var attempts = 0;
Signal.Lazy(() => ++attempts < 3
? Signal.Fail<string>(new TimeoutException())
: Signal.Emit("ok"))
.Reattempt(3)
.Subscribe(text => Console.WriteLine($"{text} after {attempts} tries"));
// prints: ok after 3 tries
Finally runs your cleanup however the subscription ends.
Signal.Sequence(1, 2)
.Finally(() => Console.WriteLine("cleaned up"))
.Subscribe(value => Console.Write(value + " "));
// prints: 1 2 cleaned up
These boil a whole signal down to one answer. The first group hands you another signal. The second group hands you a task or a plain value, so you leave signals behind.
| Operator | What it does | LINQ / System.Reactive name |
|---|---|---|
Fold(seed, accumulator) |
Emits the running total after every value. | Scan |
Scan(seed, accumulator) |
Another name for Fold. |
Scan |
Reduce(seed, accumulator) |
Emits one final total when the source completes. | Aggregate |
Aggregate(seed, accumulator) |
Another name for Reduce. |
Aggregate |
Count(), Count(predicate) |
Emits how many values arrived, or how many matched. | Count |
LongCount(), LongCount(predicate) |
Does the same as a 64-bit number. | LongCount |
Any(), Any(predicate) |
Emits whether at least one value arrived, or matched. | Any |
All(predicate) |
Emits whether every value matched. | All |
Contains(value), Contains(value, comparer) |
Emits whether that value ever arrived. | Contains |
IsEmpty() |
Emits whether the source completed without a value. | IsEmpty |
CollectList() |
Gathers every value and emits one list when the source completes. | ToList |
CollectArray() |
Does the same and emits an array. | ToArray |
ToList() |
Another name for CollectList. |
ToList |
ToArray() |
Another name for CollectArray. |
ToArray |
FirstAsync(), FirstAsync(cancellationToken) |
Returns a task for the first value, and fails when the source is empty. | FirstAsync().ToTask() |
FirstOrDefaultAsync() and its token, default-value and combined overloads |
Returns a task for the first value, or your fallback when the source is empty. | FirstOrDefaultAsync |
LastAsync(), LastAsync(cancellationToken) |
Returns a task for the final value. | LastAsync().ToTask() |
LastOrDefaultAsync() and its token, default-value and combined overloads |
Returns a task for the final value, or your fallback when the source is empty. | LastOrDefaultAsync |
ToTask(), ToTask(cancellationToken) |
Returns a task that gives you the last value once the source completes. | ToTask() |
Signal.ToTask(source), Signal.ToTask(source, cancellationToken) |
Static form of ToTask. |
ToTask |
CountAsync() and its predicate and token overloads |
Returns a task for the value count. | Count().ToTask() |
AnyAsync() and its predicate and token overloads |
Returns a task for whether anything arrived or matched. | Any().ToTask() |
CollectArrayAsync() |
Returns a task for every value as an array. | ToArray().ToTask() |
CollectListAsync() |
Returns a task for every value as a list. | ToList().ToTask() |
ToArrayAsync() |
Another name for CollectArrayAsync. |
- |
ToListAsync() |
Another name for CollectListAsync. |
- |
ToEnumerable() |
Blocks the calling thread until the source completes, then hands back the values. | ToEnumerable |
GetAwaiter(), GetAwaiter(cancellationToken) |
Lets you await the signal for its last value. |
GetAwaiter |
Signal.RunAsync(source), Signal.RunAsync(source, cancellationToken) |
Subscribes at once and returns an awaiter for the final value. | RunAsync |
HandleCancellation(token), HandleCancellation(action, token) |
Awaits the final value and returns default instead of failing when the token cancels. |
- |
FirstAsTaskHelper.FirstAsTask(source) |
Returns a task for the first value. | FirstAsync().ToTask() |
FirstAsValueTaskHelper<T>.FirstAsValueTask(source) |
Does the same as a ValueTask<T> that allocates less. |
- |
Fold shows the running total as it grows.
Signal.Sequence(1, 4)
.Fold(0, (total, number) => total + number)
.Subscribe(total => Console.Write(total + " "));
// prints: 1 3 6 10
Reduce gives you the total once, at the end.
Signal.Sequence(1, 4)
.Reduce(0, (total, number) => total + number)
.Subscribe(total => Console.WriteLine(total));
// prints: 10
Count tells you how many values matched.
new[] { "a", "bb", "ccc" }.ToSignal()
.Count(text => text.Length > 1)
.Subscribe(count => Console.WriteLine(count));
// prints: 2
CollectList gathers everything into one list.
Signal.Sequence(1, 3)
.CollectList()
.Subscribe(list => Console.WriteLine(string.Join(",", list)));
// prints: 1,2,3
FirstAsync gives you a task for the first value.
var first = await Signal.Sequence(7, 3).FirstAsync();
Console.WriteLine(first);
// prints: 7
You can await a signal directly for its last value.
var last = await Signal.Sequence(1, 5);
Console.WriteLine(last);
// prints: 5
These cover subscribing, choosing threads, watching values go past, cleaning up, and sharing one subscription between several subscribers.
A connectable signal waits for a Connect() call before it subscribes to its source. That lets several subscribers
share one subscription instead of starting the work over each time.
| Operator | What it does | LINQ / System.Reactive name |
|---|---|---|
Subscribe() |
Starts the signal and ignores its values. | Subscribe() |
Subscribe(onNext) |
Runs your callback for each value, and rethrows a terminal error to the producer. | Subscribe |
Subscribe(onNext, onCompleted) |
Adds a callback for completion. | Subscribe |
Subscribe(onNext, onError) |
Adds a callback for errors. | Subscribe |
Subscribe(onNext, onError, onCompleted) |
Takes all three callbacks. | Subscribe |
SubscribePrimitives() and its 4 overloads |
Gives you the same five methods under a name that cannot clash with another library. | Subscribe |
SubscribeSafe(observer) |
Subscribes and keeps your observer's exceptions away from the producer. | SubscribeSafe |
SubscribeSafePrimitives(observer) |
Gives you the same method under a name that cannot clash. | SubscribeSafe |
SubscribeSafe(onNext), SubscribeSafe(onNext, onError), SubscribeSafe(onNext, onError, onCompleted) |
Callback forms of SubscribeSafe. A lone delegate is onNext. With no error handler, a source error is rethrown. |
SubscribeSafe |
SubscribeSafeErrors(onError), SubscribeSafeErrors(onError, onCompleted) |
Subscribes with error and completion callbacks only. Values are ignored. | None |
LinqExtensions.SubscribeSafe(source, ...), 12 static overloads, and LinqExtensions.SubscribeSafeErrors(source, ...), 6 static overloads |
Lets a nullable source pick one overload without ambiguity; the params array is a marker and is never read. |
SubscribeSafe |
IObserver<T>.FastForEach(source) |
Pushes a whole collection into an observer and indexes arrays and lists directly. | - |
ObserveOn(sequencer) |
Delivers notifications to subscribers on the sequencer you name. | ObserveOn |
WitnessOn(sequencer) |
Another name for ObserveOn. |
ObserveOn |
WitnessLatestOn(sequencer) |
Delivers notifications on the sequencer you name. Keeps only the newest value that is waiting and drops the older ones. | - |
SubscribeOn(sequencer) |
Runs the subscription itself on the sequencer you name. | SubscribeOn |
Synchronize(), Synchronize(object gate) |
Delivers notifications one at a time behind a lock, which you can share with other signals. | Synchronize |
Synchronize(Lock gate) |
The same, taking a System.Threading.Lock. Available on net9.0 and later only. |
Synchronize |
Serialize() |
Delivers notifications one at a time and holds no lock while your code runs, so a late arrival queues instead of blocking. | Synchronize (deadlock-safe) |
Tap(onNext) |
Runs your action for each value and passes the value through unchanged. | Do |
Tap(onNext, onError, onCompleted) |
Does the same and hooks errors and completion too. | Do |
TapWith(state, onNext) |
Works like Tap and threads a state object through, so your lambda can be static. |
Do |
Do(onNext) and its 3 overloads |
Another name for Tap. |
Do |
DoWith(state, onNext) |
Another name for TapWith. |
Do |
AsObservable() |
Wraps the signal in a read-only view, so a caller cannot cast it back and push values in. | AsObservable |
ToSignal() on a signal |
Hands back the same signal after a null check. | AsObservable |
IDisposable.DisposeWith() |
Wraps a disposable so the wrapper disposes it exactly once. | - |
IDisposable.DisposeWith(action) |
Does the same and runs your action just before disposal. | - |
T.DisposeWith(MultipleDisposable) |
Hands the disposable to a group and returns it, so you chain it onto the line that creates it. | DisposeWith |
ShareLive() |
Wraps the source in a connectable signal that starts when you call Connect(). |
Publish |
Publish() |
Another name for ShareLive. |
Publish |
Share() |
A third name for ShareLive. |
Publish |
Publish(selector) |
Shares the source for the length of one expression, so it is subscribed once. | Publish(selector) |
ReplayLive() |
Wraps the source in a connectable signal that replays every past value to a late subscriber. | Replay |
ReplayLive(bufferSize) |
Replays the last few values, up to the size you name. | Replay(bufferSize) |
ReplayLive(bufferSize, window) |
Replays values limited by both count and age. | Replay(n, window) |
Replay(), Replay(bufferSize), Replay(bufferSize, window) |
Another name for the three ReplayLive overloads. |
Replay |
Multicast(hub) |
Pushes the source through a hub you supply. | Multicast |
AutoShare() |
Connects on the first subscriber and disconnects when the last one leaves. | RefCount |
RefCount() |
Another name for AutoShare. |
RefCount |
AutoConnect() |
Connects on the first subscriber and never disconnects. | AutoConnect |
AutoConnect(subscriberCount) |
Waits for that many subscribers, then connects. | AutoConnect(n) |
AutoConnect(subscriberCount, onConnect) |
Does the same and hands you the connection to dispose. | AutoConnect(n, onConnect) |
ShareLatest() |
Shares one live subscription for as long as anyone listens, and drops it when the last one leaves. It does not replay: a late subscriber sees nothing until the next value, despite the name. | Publish().RefCount() |
ToReadOnlyState(initialValue, selector) |
Turns a signal into an object with a current Value and a Changed signal. Changed sends the current value when you subscribe, then once per source value, including when your selector returns the same value again. |
ToProperty, which notifies only on a real change |
Subscribe starts the signal. Dispose the result to stop listening.
using var subscription = Signal.Sequence(1, 3).Subscribe(
value => Console.Write(value + " "),
error => Console.WriteLine(error.Message),
() => Console.WriteLine("done"));
// prints: 1 2 3 done
Tap watches values go past without changing them. It is handy for logging.
Signal.Sequence(1, 3)
.Tap(value => Console.Write($"saw {value} "))
.Keep(value => value > 1)
.Subscribe(value => Console.Write($"kept {value} "));
// prints: saw 1 saw 2 kept 2 saw 3 kept 3
ObserveOn moves delivery onto the thread you want.
downloads
.ObserveOn(uiSequencer)
.Subscribe(file => label.Text = file.Name);
// the label is set on the UI thread
DisposeWith collects subscriptions so you can stop them together.
var subscriptions = new MultipleDisposable();
Signal.Every(TimeSpan.FromSeconds(1))
.Subscribe(tick => Console.WriteLine(tick))
.DisposeWith(subscriptions);
subscriptions.Dispose();
// stops every subscription in the group at once
ShareLatest gives two subscribers one shared source instead of two.
var shared = Signal.Every(TimeSpan.FromSeconds(1)).ShareLatest();
shared.Subscribe(tick => Console.WriteLine("a " + tick));
shared.Subscribe(tick => Console.WriteLine("b " + tick));
// both subscribers see the same ticks from one timer
ToReadOnlyState gives you a value you can read at any moment, plus a signal of changes.
using var name = people.ToReadOnlyState("unknown", person => person.Name);
Console.WriteLine(name.Value);
name.Changed.Subscribe(value => Console.WriteLine(value));
// prints: unknown, then each new name as it changes
ReactiveUI.Primitives ships a large set of extension helpers on top of the core operators. They live on a static class
called ReactiveExtensions, they sit in the namespace ReactiveUI.Primitives.Extensions, and they ship inside the main
ReactiveUI.Primitives package, so you get them with no extra reference.
A few words come up in every table. A source is a sequence of values you subscribe to. A sequencer decides which
thread runs your code; you pass one in when you care where the work lands. A subscription is the IDisposable you
get back when you subscribe; dispose it to stop listening. RxVoid is the stand-in for a value that carries no
information.
To use these helpers, add:
using ReactiveUI.Primitives; // Subscribe(onNext)
using ReactiveUI.Primitives.Extensions; // the helpers below
using ReactiveUI.Primitives.Signals; // Signal<T>
These turn something that is not a sequence into one.
| Member | What it does |
|---|---|
Observables.Return(value) |
Emits one value and completes, both inside the Subscribe call. |
ReactiveExtensions.Start(function, sequencer) |
Runs the function once per subscriber, emits its result, then completes. |
action.Start(sequencer) |
Runs the action once per subscriber, emits RxVoid, then completes. |
condition.While(action) |
Runs the action over and over on the calling thread while the condition returns true. |
condition.While(action, sequencer) |
Runs each round of the loop on the sequencer instead of the calling thread. |
enumerable.FromArray() |
Emits each element of the collection in order. |
enumerable.FromArray(sequencer) |
Emits each element of the collection on the sequencer. |
resource.Using(action) |
Runs the action against the resource, emits RxVoid, completes, then disposes the resource. |
resource.Using(action, sequencer) |
Same as above, with the action run on the sequencer. |
resource.Using(function) |
Runs the function against the resource, emits its result, completes, then disposes the resource. |
resource.Using(function, sequencer) |
Same as above, with the function run on the sequencer. |
tasks.WithLimitedConcurrency(maxConcurrency) |
Runs the tasks with at most maxConcurrency in flight and emits results as they finish. |
owner.ToPropertyObservable(propertyExpression) |
Emits the property value on subscribe, then again each time that property raises a change. |
ReactiveExtensions.ToReadOnlyBehavior(initialValue) |
Returns a read side and a write side that share one latest value. |
These change each value into a different value.
| Member | What it does |
|---|---|
source.AsSignal() |
Replaces every value with RxVoid, so only the timing survives. |
source.SelectConstant(constant) |
Replaces every value with the constant you pass in. |
source.TrySelect(selector) |
Runs the selector on each value and forwards only the results that are not null. |
source.WhereSelect(predicate, selector) |
Keeps the values the predicate accepts and runs the selector on those, in one step. |
source.SelectManyThen(first, second) |
Feeds each value through two sequence-returning selectors in a row. |
source.ScanWithInitial(initial, accumulator) |
Emits the initial value, then the running total after each source value. |
source.Pairwise() |
Emits each next-door pair as (Previous, Current), so the first value alone emits nothing. |
source.ForEach() |
Flattens a source of collections into one value at a time. |
source.ForEach(sequencer) |
Flattens a source of collections and delivers the values on the sequencer. |
source.Shuffle() |
Reorders each array in place at random and forwards that same array. |
source.Not() |
Flips each boolean value. |
source.SelectAsync(asyncSelector) |
Runs the async selector for each value and emits the results in source order. |
source.SelectAsyncSequential(selector) |
Same as SelectAsync, under a name that states the ordering. |
source.SelectLatestAsync(selector) |
Runs the async selector for each value and emits only the newest result. |
source.SelectAsyncConcurrent(selector, maxConcurrency) |
Runs the async selector with a cap on parallel calls and emits results as they finish. |
source.BufferUntil(startsWith, endsWith) |
Gathers characters between the two marker characters into a string, markers included. |
source.ReplayLastOnSubscribe(initialValue) |
Emits the initial value to each new subscriber before the source values. Each subscriber gets its own subscription, so a late subscriber receives the initial value, not the newest one. The async operator of the same name shares one subscription and replays the newest value instead. |
source.LatestOrDefault(defaultValue) |
Emits the default on subscribe, then each value that differs from the one before it. |
These drop values you do not want.
| Member | What it does |
|---|---|
source.WhereIsNotNull() |
Drops null values and passes everything else through. The element type is unchanged, so a nullable source stays nullable downstream. The async operator of this name narrows T? to T. |
source.WhereTrue() |
Keeps only the true values. |
source.WhereFalse() |
Keeps only the false values. |
source.SkipWhileNull() |
Drops nulls until the first non-null value, then forwards everything, nulls included. |
source.TakeUntil(predicate) |
Forwards values up to and including the first match, then completes. |
source.WaitUntil(predicate) |
Emits only the first matching value, then completes. |
source.Filter(regexPattern) |
Keeps the strings that match the pattern, using a 30 second match timeout. |
source.Filter(regex) |
Keeps the strings that match the regular expression you built yourself. |
source.Partition(predicate) |
Splits the source into a true sequence and a false sequence that share one subscription. Over a cold source the first side to subscribe consumes it, so share the source first when both sides need it. |
source.DropIfBusy(asyncAction) |
Runs the async action for a value and drops any value that arrives while it is running. |
These mix several sources into one.
| Member | What it does |
|---|---|
sources.CombineLatestValuesAreAllTrue() |
Emits true while the newest value of every source is true. |
sources.CombineLatestValuesAreAllFalse() |
Emits true while the newest value of every source is false. |
source.GetMax(sources) |
Emits the largest of the newest values, once every source has emitted. |
source.GetMin(sources) |
Emits the smallest of the newest values, once every source has emitted. |
source.SwitchIfEmpty(fallback) |
Switches to the fallback when the source completes without emitting anything. |
source.SampleLatest(trigger) |
Emits the newest source value each time the trigger fires. |
sources.RunAll() |
Runs the sources one after another, then emits RxVoid and completes. |
candidates.FirstMatchFromCandidates(project, transform, predicate, fallback) |
Tries each candidate in order and emits the first match, or the fallback when none match. |
These change when a value reaches you.
| Member | What it does |
|---|---|
source.ThrottleFirst(window) |
Emits the first value in each window and drops the rest of that window. |
source.ThrottleFirst(window, sequencer) |
Same as above, with the sequencer supplying the clock. |
source.ThrottleOnScheduler(timeSpan, sequencer) |
Emits the newest value once the gap since the last one reaches timeSpan. |
source.ThrottleDistinct(throttle) |
Emits the newest value after the throttle window, and skips it when it repeats the last one emitted. |
source.ThrottleDistinct(throttle, sequencer) |
Same as above, with the sequencer supplying the clock. |
source.ThrottleUntilTrue(throttle, predicate) |
Emits a matching value right away and delays every other value by the throttle. |
source.DebounceImmediate(dueTime) |
Emits the first value right away, then the newest value after each quiet stretch. |
source.DebounceImmediate(dueTime, sequencer) |
Same as above, with the sequencer supplying the clock. |
source.DebounceUntil(debounce, condition) |
Emits a matching value right away and delays every other value by the debounce time. |
source.DebounceUntil(debounce, condition, sequencer) |
Same as above, with the sequencer supplying the clock. |
source.Conflate(minimumUpdatePeriod, sequencer) |
Keeps emissions at least that far apart and holds back only the newest waiting value. |
source.BufferUntilIdle(idleTime) |
Collects values into a list and emits the list once the source goes quiet. |
source.BufferUntilIdle(idleTime, sequencer) |
Same as above, with the sequencer supplying the clock. |
source.BufferUntilInactive(inactivityPeriod) |
Another name for BufferUntilIdle. |
source.BufferUntilInactive(inactivityPeriod, sequencer) |
Another name for BufferUntilIdle with a sequencer. |
source.DetectStale(stalenessPeriod, sequencer) |
Wraps each value as an update and emits a stale marker for each quiet stretch. |
source.Heartbeat(heartbeatPeriod, sequencer) |
Wraps each value as an update and emits a heartbeat every period the source stays quiet. |
| `tim |
reactiveui/Primitives is a public repo on GitHub by reactiveui. A compact, allocation-conscious reactive programming library for .NET built on IObservable<T>. It covers the common Rx operators, scheduling and state without a runtime dependency on System.Reactive, and is designed for trimming and native AOT.
It declares the MIT license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2026-11-21. Take My Repo does not judge from that whether it is maintained.
State machines, statecharts, and actors for complex logic

Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
A book series (2 published editions) on the JS language.
The Free Software Media System - Server Backend & API
The automatic type-safe REST library for .NET. Refit turns a REST API into a C# interface and generates the HttpClient implementation, with support for HttpClientFactory, pluggable serializers and a testing package.
A composable, cross-platform MVVM framework for .NET inspired by functional reactive programming. It moves mutable state out of the user interface, keeps each feature's logic in one readable place, and makes applications easier to test. Supports WPF, WinForms, WinUI, .NET MAUI, Avalonia, Uno Platform, Blazor and Android.
An asynchronous, persistent key-value store for .NET desktop and mobile applications, backed by SQLite. Suited to both durable data such as user settings and cached data that expires, with optional encryption and System.Text.Json serialization.
Cross-platform building blocks for .NET applications. Provides service location and dependency resolution, logging, platform-neutral images, colours and geometry, and unit test and design mode detection.
A cross-platform sample application built with ReactiveUI. Camelotia is a file manager for cloud storage providers and local file systems, demonstrating reactive MVVM architecture, testable view models and shared code across desktop UI frameworks.
Take My Repo has not tested this on your machine. Requirements come from the project's own documentation.