@signal-kernel/core
v0.1.6
Published
Framework-agnostic fine-grained reactive graph runtime with lazy computed values, deterministic effects, and batching.
Maintainers
Readme
Installation
npm install @signal-kernel/coreQuick Start
import { signal, computed, createEffect } from "@signal-kernel/core";
const count = signal(0);
const doubled = computed(() => count.get() * 2);
createEffect(() => {
console.log("doubled =", doubled.get());
});
count.set(1);
count.set(2);Output:
doubled = 2
doubled = 4What is this?
@signal-kernel/core is a framework-agnostic reactive runtime.
It provides the minimal primitives needed to build reactive systems:
signal()— mutable statecomputed()— lazy derived valuescreateEffect()— reactive side effectsbatch()— update coalescing- deterministic scheduler
Unlike frameworks (React, Vue), this library:
- does not render UI
- does not manage DOM
- focuses purely on reactive dataflow and execution order
When to use this
Use @signal-kernel/core if you need:
Fine-grained reactivity (no VDOM diffing)
Deterministic update ordering
A foundation for building:
- UI adapters (React/Vue/Solid)
- async data pipelines
- reactive state machines
- server-side reactive graphs
This is not a UI framework — it is a low-level reactive kernel.
Core Concepts
signal()
const count = signal(0);
count.get();
count.peek();
count.set(1);computed()
const doubled = computed(() => count.get() * 2);createEffect()
createEffect(() => {
console.log(count.get());
});batch()
batch(() => {
count.set(1);
count.set(2);
});Scheduler Model
This runtime separates synchronous graph invalidation from scheduled side effects:
- Signal writes mark dependent computed nodes as stale.
- Effects reached by invalidation are deduplicated and scheduled.
- Scheduled effects execute in deterministic order.
- A stale computed value recomputes lazily only when a consumer reads it.
Computed nodes without an active read remain stale and do not perform work. Once recomputed, their values stay cached until another dependency change.
Architecture Overview
For full details, see:
Public API
export { signal } from "./signal.js";
export { computed } from "./computed.js";
export { createEffect, onCleanup } from "./effect.js";
export { batch } from "./scheduler.js";Design Goals
- Deterministic scheduling
- Lazy computation
- Explicit dependency graph
- Zero framework assumptions
- Adapter-friendly architecture
Ecosystem
@signal-kernel/core is the foundation of the Signal Kernel ecosystem.
Current companion packages:
@signal-kernel/async-runtime@signal-kernel/react@signal-kernel/vue
Planned companion packages:
- snapshot and transfer packages
License
MIT © Luciano
