AsterDocsv1.2.3

Docs / Architecture

Generators and slots

A generator keeps its local variables between calls to .next(). Aster uses that property for interactive components. A counter can declare its count before the render loop, change it in a click handler, and read the new value on the next pass. A plain function is enough for a badge that just displays its props.

How a click reaches the DOM

The compiler separates the static markup in a JSX expression from its changing parts. For a button with a changing label, the template describes the button and the slot identifies where the text goes. On a click, the handler updates the local variable. Aster schedules the component, advances its generator, and compares the new slot values with the previous ones. Try changing the label of a mounted counter, then increment it again. Its count belongs to that component instance. Change the props of a running counter.

Read the compiler output

Here is the input to the Aster 1.2.3 Vite transform for /src/Counter.jsx.

jsx
export function* Counter() {
  let count = 0;
  for (;;) yield <button onClick={() => count++}>{count}</button>;
}

These two expressions come from that transform’s output, with line breaks added. In the first expression, path [0] points to the button. Path [0, 0] identifies its first child. In the second, the event handler and count appear in the same order as the bindings.

js
const _t1 = _tpl(
  '<button data-aster-a0=""><!--aster:1--></button>',
  [
    { kind: 'attr', name: 'onClick', path: [0] },
    { kind: 'node', path: [0, 0] }
  ]
);

// Inside the generator's loop
yield _slot(_t1, [() => count++, count]);

Where the model needs care

A callback passed to a timer can change the same local variable, but the timer runs outside the component's DOM event handling. Call ctx.refresh() after the change, or read a signal while rendering and update it from the callback. An uncaught exception closes a JavaScript generator. An error boundary's reset starts a new instance, including its initialization code. Trigger and recover from a failed request.

Why delegate a step?

A confirmation can yield its own controls until the user chooses an action, then return a boolean to its caller. While the step is active, JavaScript forwards advances of the outer generator to the inner one. Closing the outer generator also gives the active step a chance to run its cleanup. Inspect a delegated confirmation or trace the order of cleanup.

Summary of the architecture decision accepted on 2026-11-23.