-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat: use lit-store internally instead of reyling on vanilla store dependency #6267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: beta
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Example: Basic Subscribe | ||
|
|
||
| This example demonstrates fine-grained state subscriptions using `SubscribeController` for optimized rendering in Lit. | ||
|
|
||
| **Key Features:** | ||
|
|
||
| - **Fine-grained subscriptions**: Each part of the table subscribes only to the state it needs | ||
| - **SubscribeController**: A new Lit ReactiveController that handles store/atom subscriptions declaratively | ||
| - **External atoms**: State management via `createAtom` from `@tanstack/store` for full control | ||
| - **Performance optimized**: Only affected UI elements re-render when their subscribed state changes | ||
|
Comment on lines
+3
to
+10
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
rg -n "SubscribeController|`@tanstack/store`|table.subscribe|`@tanstack/lit-store`" \
examples/lit/basic-subscribe/README.md \
examples/lit/basic-subscribe/src/main.tsRepository: TanStack/table Length of output: 1393 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Search for SubscribeController / `@tanstack/store` in example =="
rg -n "SubscribeController|`@tanstack/store`" examples/lit/basic-subscribe || true
echo
echo "== Search for table.subscribe / `@tanstack/lit-store` in example =="
rg -n "table\.subscribe|`@tanstack/lit-store`" examples/lit/basic-subscribe || true
echo
echo "== Show README lines 1-40 =="
sed -n '1,40p' examples/lit/basic-subscribe/README.mdRepository: TanStack/table Length of output: 2567 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== package.json deps =="
cat examples/lit/basic-subscribe/package.json | sed -n '1,80p'
echo
echo "== main.ts import and table.subscribe usage (around top) =="
sed -n '1,120p' examples/lit/basic-subscribe/src/main.ts
echo
echo "== main.ts table.subscribe call signature (around first occurrence) =="
sed -n '160,260p' examples/lit/basic-subscribe/src/main.tsRepository: TanStack/table Length of output: 7469 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== package.json deps =="
cat examples/lit/basic-subscribe/package.json | sed -n '1,80p'
echo
echo "== main.ts import and table.subscribe usage (around top) =="
sed -n '1,120p' examples/lit/basic-subscribe/src/main.ts
echo
echo "== main.ts table.subscribe call signature (around first occurrence) =="
sed -n '160,260p' examples/lit/basic-subscribe/src/main.tsRepository: TanStack/table Length of output: 7469 Fix outdated README API names in The README claims the example uses Suggested doc fix-This example demonstrates fine-grained state subscriptions using `SubscribeController` for optimized rendering in Lit.
+This example demonstrates fine-grained state subscriptions using `table.subscribe(...)` for optimized rendering in Lit.
- **Fine-grained subscriptions**: Each part of the table subscribes only to the state it needs
-- **SubscribeController**: A new Lit ReactiveController that handles store/atom subscriptions declaratively
-- **External atoms**: State management via `createAtom` from `@tanstack/store` for full control
+- **`table.subscribe` directive**: A Lit async directive for declarative store/atom subscriptions
+- **External atoms**: State management via `createAtom` from `@tanstack/lit-store` for full control🤖 Prompt for AI Agents |
||
|
|
||
| **What this shows:** | ||
|
|
||
| 1. Global filter input that re-renders only when global filter changes | ||
| 2. Table rows that re-render only when filtering/pagination state changes | ||
| 3. Pagination controls that re-render only when pagination state changes | ||
| 4. Row selection summary that re-renders only when selection changes | ||
| 5. Full table state display for debugging | ||
|
|
||
| This pattern is ideal for large tables where you want to minimize unnecessary re-renders and have precise control over which components subscribe to which state slices. | ||
|
|
||
| ## Running the Example | ||
|
|
||
| To run this example: | ||
|
|
||
| - `npm install` or `yarn` | ||
| - `npm run start` or `yarn start` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>TanStack Lit Table - Basic Subscribe</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script type="module" src="/src/main.ts"></script> | ||
| <lit-table-example></lit-table-example> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "name": "tanstack-lit-table-example-basic-subscribe", | ||
| "private": true, | ||
| "scripts": { | ||
| "dev": "vite", | ||
| "build": "vite build", | ||
| "serve": "vite preview", | ||
| "start": "vite", | ||
| "lint": "eslint ./src" | ||
| }, | ||
| "dependencies": { | ||
| "@faker-js/faker": "^10.4.0", | ||
| "@tanstack/lit-store": "^0.13.2", | ||
| "@tanstack/lit-table": "^9.0.0-beta.6", | ||
| "lit": "^3.3.3" | ||
| }, | ||
| "devDependencies": { | ||
| "@rollup/plugin-replace": "^6.0.3", | ||
| "typescript": "6.0.3", | ||
| "vite": "^8.0.16" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix method name:
setOption→setOptions.The method name should be
setOptions(plural), notsetOption(singular). This typo would cause a runtime error.📝 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents