Skip to content

Refactor: unify anyCardOpen (MutationObserver) and tapPaused (callback) plumbing in the Scrambler parent #53

Description

@khurchla

Surfaced by the clarity-review pass on the v0.1.0 release branch (B6). Do NOT apply for v0.1.0 — captured for post-launch.

src/components/Scrambler.svelte:39-54 derives anyCardOpen by mounting a MutationObserver that watches every descendant's class attribute for .scrambler-card.focused / .scrambler-card.expanded — an indirect, attribute-string-sniffing channel.

tapPaused (lines 34-37, added by #43) is a clean callback hoisted from each cluster.

Both signals do the same job — coordinate cross-cluster state in the parent — but use different mechanisms. The MutationObserver works only because the card writes those exact class names, which is a hidden coupling. The callback pattern is explicit and testable.

Proposed unification: hoist an onCardOpenChange(delta: 1 | -1) callback from ScramblerCard → ScramblerCluster → Scrambler. Maintain a cardOpenCount on the parent; anyCardOpen = cardOpenCount > 0. Drop the observer.

Files

  • src/components/Scrambler.svelte
  • src/components/ScramblerCluster.svelte
  • src/components/ScramblerCard.svelte

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions