Skip to content

refactor(store): simplify controller and state APIs#352

Merged
mihar-22 merged 1 commit intomainfrom
refactor/store-simplify-controllers
Jan 28, 2026
Merged

refactor(store): simplify controller and state APIs#352
mihar-22 merged 1 commit intomainfrom
refactor/store-simplify-controllers

Conversation

@mihar-22
Copy link
Copy Markdown
Member

Summary

Simplifies the store package APIs by creating a shared SubscriptionController base for Lit controllers and removing unused utilities.

Changes

  • Create SubscriptionController as shared base that handles store resolution (direct or context) and subscription lifecycle
  • QueueController and StoreController are now thin wrappers that configure what to subscribe to
  • SubscriptionController implements ReactiveController and registers itself with the host
  • Simplify StateChange callback signature — no longer passes changedKeys to callbacks (internal tracking preserved)
  • Add useMemo to React hooks for stable object references
  • Remove unused extendConfig utility and tests
Implementation details

Controller hierarchy:

SubscriptionController       ← handles context + subscription lifecycle
├── StoreController          ← subscribes to store state
└── QueueController          ← subscribes to queue tasks

SnapshotController           ← self-contained (State<T> directly)

Test improvements:

  • Replaced mock host with TestHostElement extends ReactiveElement
  • Tests use real DOM lifecycle (appendChild/remove) instead of simulating hostConnected/hostDisconnected

Testing

pnpm -F @videojs/store test — 238 tests pass

- Create SubscriptionController as shared base for Lit controllers
- QueueController/StoreController are now thin wrappers over SubscriptionController
- SubscriptionController implements ReactiveController and handles lifecycle
- Simplify StateChange callback signature (no longer passes changedKeys)
- Add useMemo to React hooks for stable object references
- Remove unused extendConfig utility
- Update tests to use real Lit lifecycle (appendChild/remove)
@vercel
Copy link
Copy Markdown

vercel bot commented Jan 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
vjs-10-website Skipped Skipped Jan 28, 2026 1:08pm

Request Review

@mihar-22 mihar-22 merged commit b332c7e into main Jan 28, 2026
4 checks passed
@mihar-22 mihar-22 deleted the refactor/store-simplify-controllers branch January 28, 2026 13:09
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