Burned.js API Reference

Comprehensive documentation for Burned.js' reactive programming toolkit with usage examples and code snippets.

Core API Methods

reactive()
function reactive(source)

Core function that creates a reactive signal from a source value. Automatically tracks dependencies and updates when the source changes.

// Basic usage
const count = reactive(0);

effect(() => {
  console.log(`Count changed to: ${count.value}`);
});

count.value = 42;
effect()
function effect(callback)

Registers a computation that will automatically re-run when any reactive dependencies it uses change.

const data = reactive({ user: "Alice", theme: "dark" });

effect(() => {
  document.title = `${data.user}'s App`;
});
derived()
function derived(reactiveSource, compute)

Derives a new signal from a source using a compute function. Only recomputes when dependencies change.

const width = reactive(100);
const height = reactive(50);
const area = derived([width, height], () => width.value * height.value);

console.log(area.value); // 5000

Utility Functions

Commonly used functions and helpers that work seamlessly with reactive signals.

signal()

Create a Manual Signal

signal(value) creates a manually managed signal with .value access pattern.

watch()

Watch Signal Changes

watch(signal, callback) executes a callback whenever the signal's value changes.

batch()

Batch Updates

batch(callback) groups multiple updates into a single reactive cycle to avoid unnecessary computations.

debounce()

Debounce Reactive Updates

debounce(signal, delay) delays execution of reactive effects for the specified time.

Advanced APIs

compute()
function compute(signal, compute)

Advanced version of derived signals with custom cleanup and disposal patterns.

const interval = reactive(1000);
const timeout = compute(interval, (dispose) => {
  const id = setInterval(() => {
    console.log(`Interval: ${interval.value}`);
  }, interval.value);
  return () => clearInterval(id);
});

Need a Live Example?

Explore working demos of Burned.js core methods in our interactive playground.