npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@volynets/reflex-runtime

v0.1.1

Published

Low-level reactive runtime for deterministic dependency tracking and push/pull propagation.

Readme

Reflex Runtime

@volynets/reflex-runtime is a low-level reactive graph engine for deterministic, host-controlled execution.

It provides the primitive building blocks required to construct reactive systems, schedulers, frameworks, state containers, and computation graphs.

Unlike most reactive libraries, Reflex separates:

  • dependency tracking,
  • graph propagation,
  • computation,
  • side-effect execution,
  • scheduling.

The runtime owns graph semantics. The host owns execution policy.


Installation

pnpm add @volynets/reflex-runtime

Core Concepts

Reflex is built around three fundamental roles:

Producer

A mutable source value.

Examples:

  • signals
  • stores
  • mutable state

Created with:

createProducer(...)

Consumer

A derived computation.

Consumers:

  • track dependencies automatically,
  • cache results,
  • recompute lazily,
  • participate in graph stabilization.

Created with:

createConsumer(...)

Read with:

readConsumer(...)

Watcher

A side-effect sink.

Watchers:

  • never participate in value propagation,
  • execute only when explicitly scheduled,
  • may return cleanup functions.

Created with:

createWatcher(...)

Executed with:

runWatcher(...)

Disposed with:

disposeWatcher(...)

Minimal Example

import {
  createProducer,
  createConsumer,
  createWatcher,
  readProducer,
  writeProducer,
  readConsumer,
  runWatcher,
} from "@volynets/reflex-runtime";

const count = createProducer(0);

const doubled = createConsumer(() => {
  return readProducer(count) * 2;
});

const effect = createWatcher(() => {
  console.log("doubled =", readConsumer(doubled));
});

writeProducer(count, 5);

console.log(readConsumer(doubled));

runWatcher(effect);

Execution Model

Reflex uses a push-pull architecture.

Push

Writes invalidate affected graph regions.

writeProducer(count, 5);

Invalidation is intentionally cheap.

No recomputation happens during propagation.


Pull

Consumers stabilize lazily when read.

readConsumer(doubled);

Only the necessary portion of the graph is recomputed.


Watchers

Watchers execute only when the host decides.

runWatcher(effect);

Reflex never performs implicit scheduling.


Host-Controlled Scheduling

Reflex intentionally does not provide:

  • automatic effect flushing,
  • microtask queues,
  • frame schedulers,
  • async orchestration,
  • rendering integration.

The host decides:

  • when to mutate,
  • when to read,
  • when to execute watchers,
  • how invalidated sinks should be scheduled.

Runtime hooks are notification points. They may enqueue work or request a host flush, but they must not synchronously execute watchers, read reactive values, or mutate the graph while the runtime is propagating, pulling, or recomputing.

Recommended scheduler shape:

import {
  runWatcher,
  runWithReactiveBatch,
  setRuntimeHooks,
} from "@volynets/reflex-runtime/internal";

const pendingWatchers = new Set();
let flushScheduled = false;
let flushing = false;

function flushWatchers() {
  if (flushing || pendingWatchers.size === 0) return;

  flushScheduled = false;
  flushing = true;
  try {
    for (const watcher of pendingWatchers) {
      pendingWatchers.delete(watcher);
      runWatcher(watcher);
    }
  } finally {
    flushing = false;
  }
}

function scheduleFlush() {
  if (flushScheduled) return;

  flushScheduled = true;
  queueMicrotask(flushWatchers);
}

setRuntimeHooks({
  sinkInvalidatedDispatcher(watcher) {
    pendingWatchers.add(watcher);
  },
  reactiveSettledDispatcher() {
    scheduleFlush();
  },
});

runWithReactiveBatch(() => {
  // write producers here
});

// Optional explicit host boundary.
flushWatchers();

Allowed inside sinkInvalidatedDispatcher:

queue.add(watcher);

Allowed inside reactiveSettledDispatcher:

queueMicrotask(flushWatchers);
requestAnimationFrame(flushWatchers);
host.schedule(flushWatchers);

Forbidden inside runtime hooks:

runWatcher(watcher);
readConsumer(node);
readProducer(node);
writeProducer(node, value);
flushEffects();

In development validation builds, Reflex reports scheduler contract violations at the boundary where they happen:

[REFLEX_SCHEDULER_REENTRANT_FLUSH]

Host scheduler executed runWatcher() synchronously from reactiveSettledDispatcher.

Other scheduler policy errors include:

REFLEX_SCHEDULER_REACTIVE_READ_IN_HOOK
REFLEX_NESTED_PULL
REFLEX_NESTED_PROPAGATION
REFLEX_HOST_HOOK_REENTERED_RUNTIME

See also:

docs/runtime/scheduler-contract.md

Untracked Reads

Reads may be performed without dependency registration.

untracked(() => {
  return readProducer(source);
});

Useful for:

  • diagnostics,
  • logging,
  • debugging,
  • metadata access.

Consumer Read Modes

Reflex exposes multiple read strategies.

readConsumer(...)
readConsumerLazy(...)
readConsumerEager(...)

Use the mode that best matches your execution model.

Most applications should start with:

readConsumer(...)

Debugging

Development tooling is available through:

import "@volynets/reflex-runtime/debug";

The runtime exposes a versioned debugging protocol suitable for:

  • graph inspection,
  • runtime diagnostics,
  • visualization tooling,
  • developer extensions.

Debug APIs are intentionally separated from the production runtime.


Internal APIs

Internal graph primitives are available through:

import "@volynets/reflex-runtime/internal";

These APIs are intended for framework authors and runtime experiments.

They are not covered by public stability guarantees.


Key Properties

  • Deterministic graph propagation
  • Lazy recomputation
  • Explicit execution
  • Host-controlled scheduling
  • Dynamic dependency tracking
  • Minimal runtime surface
  • Framework-agnostic design

Use When

  • Building a reactive framework
  • Building a scheduler
  • Building a state container
  • Researching reactive execution models
  • You need explicit control over computation timing

Do Not Use When

  • You want automatic effect scheduling
  • You want a UI framework
  • You need batteries-included state management
  • You prefer implicit execution semantics

Package Structure

@volynets/reflex-runtime
├─ runtime primitives
├─ graph propagation
├─ dependency tracking
├─ watcher execution
└─ scheduling hooks

@volynets/reflex-runtime/debug
└─ debugging protocol

@volynets/reflex-runtime/internal
└─ unstable internal APIs

Status

Experimental.

The runtime core is considered usable.

Diagnostics, tooling, and higher-level framework layers continue to evolve.