Skip to content

Add onSettled (handler form) and onFlush (EF-7, EF-8) - #10

Merged
ryansolid merged 2 commits into
mainfrom
claude/project-thread-df9ug2
Oct 27, 2026
Merged

ryansolid merged 2 commits into
mainfrom
claude/project-thread-df9ug2

Conversation

@ryansolid

@ryansolid ryansolid commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Requested by Ryan · project thread

What

Before this PR, the spec covered onSettled only in its owned form, effect () { … } (EF-4). It had nothing for Solid's onFlush (solidjs/solid#4292), and W-3 and AC-1 ruled it out ("to land something now, make it a guess or a separate event"). This PR adds both as functions of the language, the way until is (AC-6): ordinary Solid calls with static checks and nothing extra at run time. Both are marked taken by default 2026-10-27.

  • EF-7 onSettled(() => B), called in imperative scope, runs B once the change the calling run belongs to has committed. That is the change its writes open, or the action that adopts them (AC-1). This is Solid's unowned form.
    • In reactive scope it is IO_IN_REACTIVE; the owned form there is effect ().
    • A cleanup return is SETTLED_CLEANUP_UNOWNED at compile time.
  • EF-8 onFlush(() => B) runs B as a separate run, and so a separate instant, right after the current one. It never waits on a hold, so B's writes commit on their own unless they join a hold (H-2, D-8).
    • W-3 is amended: a run still can't split itself, but onFlush schedules another run.
    • AC-1 and 07 §5 now point at onFlush for writes that should land now.
  • Diagnostics: a closure with no parameters is required for both (HOOK_CALLBACK, new). Solid's ON_FLUSH_IN_OWNED_SCOPE warning becomes a static error. spec/99 is updated.

ref/ and the crate

Scenarios

  • S-flush-1: a menu closes now while the next page loads. The variant without onFlush waits for the page.
  • S-settled-1: Solid's save-button toast example, plus a variant where nothing is held.

Runs (ref/SOLID_NEXT 0847122)

runner result
interpreter 99/99
oracle 99/99 (9 recorded divergences, unchanged)
compiled 99/99, and 99/99 on the crate's output (RX_CRATE=1)
ssr 92 pass, 0 fail, 7 skip
types 137/137
npm --prefix ref run crate 286/286 agree
crate -- --lower 166/166 alike

The oracle runs Solid's own functions and agrees with the spec's frames on both new scenarios.

🤖 Generated with Claude Code

https://claude.ai/code/session_0117BoWNyLJmSs7V2omSfCrh

… EF-8)

onSettled(() => B) in imperative scope runs B after the change the calling
run belongs to commits; onFlush(() => B) runs B as its own instant right
after the current one, so a write can stay out of another write's hold.
Both are Solid's own functions; in reactive scope they are IO_IN_REACTIVE
(the owned onSettled is effect () { ... }), a non-closure argument is
HOOK_CALLBACK, and an onSettled cleanup return is SETTLED_CLEANUP_UNOWNED
at compile time. Scenarios S-flush-1 and S-settled-1 pass every runner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0117BoWNyLJmSs7V2omSfCrh
@ryansolid ryansolid self-assigned this Oct 27, 2026
compiler/src/check.rs: onSettled/onFlush checks (IO_IN_REACTIVE,
HOOK_CALLBACK, SETTLED_CLEANUP_UNOWNED) as in ref/src/check.ts.
compiler/src/emit.rs: lowers both to __rt.onSettled/__rt.onFlush.
npm --prefix ref run crate: 286/286 agree; --lower: 166/166.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0117BoWNyLJmSs7V2omSfCrh
@ryansolid
ryansolid merged commit 7749fda into main Oct 27, 2026
7 checks passed
ryansolid pushed a commit that referenced this pull request Oct 27, 2026
Conflicts: Cargo.toml's crate-type comment (both builds use the cdylib),
emit.rs's EF-7/EF-8 call and check.rs's returns_closure/hook check ported to
the span-carrying AST (ExprKind/StmtKind), spec/11's decisions renumbered
(main's 7 stays; the editor's are 8, 9, 10). The projection's BUILTINS and
prelude take onSettled/onFlush (ref/crate.ts --project 170/170).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0117BoWP4zNW5bnup8XRB8md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants