Roc Signals
Roc Signals is a Roc platform for interactive browser applications. You write the whole UI in pure Roc: elements, the state they read, the decisions that change it, and the effects it asks for. The platform compiles your app and its reactive engine to WebAssembly. A small JavaScript runtime applies the DOM commands the engine emits and performs the effects it requests.
There is no virtual DOM. Your view runs once, when the app starts. After that, when an event writes a piece of state, the engine re-evaluates only the text, attributes and structure that read that state, and skips any value that comes out equal to what is already on the page. That holds for a list too: an edit to one row of a long table touches that row.
State has three homes. What the whole app shares is in a store, read from any depth of the view. Rows the user edits are in a table, drawn through a sorted, filtered window. What one piece of the view cares about is local to it. Shared state is changed by decisions: pure functions that return what they write, which you test as functions.
What a user sees and does is tested without a browser too. Specs written in a
small .scm language run natively against the same engine in milliseconds,
and the same specs replay in headless Chrome.
Use ordinary HTML and CSS. The examples on this site use Tailwind classes, but the platform does not depend on any CSS framework.
Where to start
- Getting Started creates a counter with
signals.roc, runs it in a browser, tests it and builds it for deployment. - Thinking in Signals explains the model: what runs when, where state lives, and what a write wakes. Read it before the topic guides.
- Tutorial builds a to-do list on a store, a table and a view of it, with local storage, and tests it.
Building an app
Read these in order; each builds on the one before.
- Local State, Events, and Forms: state that belongs to one piece of the view, handlers, controlled inputs, derived values, and starting state again.
- Markup Literals: checked HTML and SVG with signal holes.
- Shared State: the store and its cells, writes as values, decisions and how to test them, and resets.
- Tables and Table Views: rows held by key, and a sorted, filtered window of them that follows each write.
- Conditionals and Lists:
when,switch,each, row identity and lifetimes. - Startup and Deferred Content: fixed entry routes, retained initial content, placeholders and later environment facts.
- Components: a type, its operations and a view that is handed the cells it uses.
- Effects and the Browser: HTTP, storage, timers, cryptography, navigation, focus and cleanup.
- Structuring an App: modules, where each piece of state goes, and keeping updates local.
Beyond the page
- Workers: running a task off the page’s thread, from a slow pure calculation to a job that reads and builds files, and preparations several tasks share.
- Files: taking a file the user chooses, drops or pastes as a handle, acting on it where the browser keeps it, and reading it in a worker.
- Files in Tasks: what a task’s job does with files: reading a chunk at a time, building new files, appending across jobs, downloading into a file, and saving.
- Monitoring Workers: where a worker job’s time goes, how busy the pool is, and what workers cost.
- Ports: reaching a browser service the platform does not model, through typed messages to JavaScript your page supplies.
Testing and reference
- Testing: decisions tested as functions, the spec language and its two runners, with every step for effects, workers, files and ports.
- Reference: the API at a glance and the platform’s limits.
- Under the Hood: how an event becomes DOM commands.
- Contributing: working on the platform itself.
The examples are complete apps, each with its specs. The code assumes you know Roc functions, records and tag unions; the Roc tutorial covers the language.