Skip to content

feat: add createSlot fallback option - #21

Merged
binjospookie merged 1 commit into
mainfrom
feat/slot-fallback
Aug 11, 2026
Merged

feat: add createSlot fallback option#21
binjospookie merged 1 commit into
mainfrom
feat/slot-fallback

Conversation

@binjospookie

Copy link
Copy Markdown
Contributor

What

createSlot({ fallback }) — an optional, prop-less component rendered while the slot has never received an insert. The first insert removes it for good: a later clear empties the slot but does not bring the fallback back. Composes with presence: true (the fallback is not probed and never counts toward useCount/usePresence).

How

The one-shot latch lives in snapshot identity instead of a mutable flag: store.clear now sets a CLEARED sentinel distinct from the initial EMPTY, and neverInserted(state) is a reference check. Render stays pure and concurrent-safe, zero allocations.

Perf

  • Slots without a fallback keep the exact same Root code path (branch happens once at createSlot time); the insert path is untouched.
  • With a fallback: one length === 0 check per Root render. No subscriptions, no probes.

Tests

12 new runtime tests, 3 type tests, 3 store tests — 152 total, plus tsc/knip/oxlint/attw/publint clean.

One deliberately changed pin: the store test "empty state is the shared EMPTY reference" is split — cleared state is now a stable shared reference distinct from the initial one (that distinction is the feature).

🤖 Generated with Claude Code

A fallback component renders while the slot has never received an
insert. The first insert removes it for good: a later clear empties
the slot but does not bring the fallback back.

The latch lives in snapshot identity: clear now sets a CLEARED
sentinel distinct from the initial EMPTY, so the render stays pure
and concurrent-safe with zero allocations. Slots without a fallback
keep the exact same Root code path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@binjospookie
binjospookie requested a review from a team August 11, 2026 14:34
@binjospookie
binjospookie merged commit d551779 into main Aug 11, 2026
3 checks passed
@binjospookie
binjospookie deleted the feat/slot-fallback branch August 11, 2026 14:37
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.

1 participant