feat: add createSlot fallback option - #21
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
createSlot({ fallback })— an optional, prop-less component rendered while the slot has never received an insert. The firstinsertremoves it for good: a laterclearempties the slot but does not bring the fallback back. Composes withpresence: true(the fallback is not probed and never counts towarduseCount/usePresence).How
The one-shot latch lives in snapshot identity instead of a mutable flag:
store.clearnow sets aCLEAREDsentinel distinct from the initialEMPTY, andneverInserted(state)is a reference check. Render stays pure and concurrent-safe, zero allocations.Perf
Rootcode path (branch happens once atcreateSlottime); the insert path is untouched.length === 0check perRootrender. 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