finds.dev

lihaoyi/scala.rx

An experimental library for Functional Reactive Programming in Scala

View on GitHub

★ 985Scalaupdated Jun 2023

// the take

Scala.Rx gives Scala programs push-based reactive variables (Var), derived reactive expressions (Rx), and side-effecting observers (Obs) that automatically recalculate when their dependencies change, with dependencies inferred by instrumenting `apply()` calls rather than declared by hand. It targets Scala (and Scala.js) developers who want FRP-style dataflow graphs embedded in otherwise imperative code, without committing to a fully monadic style.

Dependency tracking is fully automatic via an implicit DynamicVariable-based capture mechanism, so you write `Rx{ a() + b() }` and the graph wires itself up instead of making you declare dependencies twice. The ownership model (`Ctx.Owner`) solves a real and non-obvious leak: dynamically created Rx instances get killed by their parent on recalculation, with the README walking through the leak and the fix with actual counters. It compiles to both JVM and Scala.js from a shared source tree, so the same reactive graph can run server-side and in the browser. The combinator set (map/flatMap/filter/reduce/fold, plus async ones like debounce/delay) mirrors the collections API closely enough that Scala developers get it for free.

Last pushed mid-2023 and still labeled 'experimental' after years of existence — no 1.0, no apparent momentum, and the author's own `lihaoyi` ecosystem has largely moved past it. The core trick relies on a `DynamicVariable`-based implicit capture scheme that predates Scala 3; there's no mention of Scala 3 / dotty support anywhere in the docs, which is a real adoption blocker today. The library explicitly cannot represent an 'empty' Rx — the README documents this as an unsolved design gap, meaning async or optional-dependency graphs need workarounds. Rx bodies can be evaluated more than once per propagation wave by design ('best-effort' dedup only), so any side effect accidentally placed in an Rx body (rather than an Obs) can silently run extra times — an easy footgun for newcomers.

We read the README, the directory tree and a key source file in October 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
985
Forks
75
Language
Scala
Last commit
10 Jun 2023

// nearby

If scala.rx isn't quite it.

All repos →