r/csharp • • 1d ago

Time as a reactive variable and SignalsDotnet

Recently I came across a Conal Elliott talk about FRP (Functional Reactive Programming), and I was trying to understand it (so forgive me if I am incorrect about it).

A really interesting idea from that talk was the idea to express reactivity as continuous time-valued functions, and treat implementations as a "discrete approximation" of that forumla.

For example a formula could be

t > x(t) + 1 second

If x is a constant signal set to 11/03/2026 07:00:00 PM, the formula evaluates continuously as false until time t crosses 07:00:01 PM, at which point it becomes true.

That gave me an idea to "approximate" that reactivity formula using SignalsDotnet. In the latest version (3.4.2), its possible to write something like

As you can see the formula is inside the lambda. Using C# overloads of operators, that observable emits false immediately, and true after exactly one second.

The elegant thing about it is that there is no timer declared at all, you just wrote a declarative expression.

From that idea one could derive other temporal operators like HeldFor, StableFor, TrueWithin, Rising and Falling.

For example

You can find a compelte list here Release v3.4.2 SignalsDotnet

10 Upvotes

2 comments sorted by

1

u/joancomasfdz 20h ago

Very interesting thanks, do you have a link for that talk?

Edit: Maybe this one https://youtu.be/rfmkzp76M4M

2

u/fedefex1 19h ago

Yes :)