-
Notifications
You must be signed in to change notification settings - Fork 87
feat(angular-db): add Angular injectLiveQuery helper with tests and example app #424
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
Conversation
- introduce injectLiveQuery for TanStack DB Angular integration - add unit tests (test-setup.ts, test-inject-query.ts) - include examples/angular/todos app demonstrating basic usage - docs: angular/adapter.md
🦋 Changeset detectedLatest commit: ca42fdb The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…r best practices - Remove deps parameter and manual dependency tracking logic from React useLiveQuery - Eliminate unnecessary signal wrappers (lastDeps, lastConfig, currentCollection) - Simplify collection creation without React-style effect dependency comparison - Use Angular signals idiomatically instead of computed wrappers - Maintain same functionality while following Angular reactivity patterns
Added an overload to use an angular/core resource style object for function parameters. If used any signals returned by the params function will rebuild the query collection. example: updated to show the new usage tests: refactored to include the new overload docs: included new usage
I think this is ready for review and some input. Would appreciate any feedback on the implementation and a lot more testing is probably needed. Happy to edit/add anything i missed. Especially curious about how I handled reactive params. I opted for an overload that allows a user to pass an object similar to how the new resource api works in angular 19+ selectedProjectId = signal(2); todoQuery = injectLiveQuery({ this is different from how other adapters are handling this by using the deps array as an argument. Happy to refactor if this isn't what you all would want to see in terms of developer experience. |
ChatGPT's review https://chatgpt.com/share/68add34d-fa48-800c-ae68-75f4fbce9455 |
@emcdaniel1624 thanks for doing this! I tested the app and it works great & ChatGPT's review says it's good 😆 I don't have any angular experience (nor anyone else on the core maintainers group) so I'm fine shipping this and assuming you and other Angular folks will come along to fix bugs & keep things going. Did you read the ChatGPT review? A few of the minor things it mentioned could be worth doing e.g. clarify return types and adding a |
The injectLiveQuery implementation uses Angular's signals API (signal, computed, effect) which was introduced in Angular 16. The previous peer dependency of >=14.0.0 was incorrect as it would allow usage with Angular versions that don't support these APIs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
… safety Export a reusable TypeScript interface for the injectLiveQuery return type to improve developer experience. The interface provides clear documentation of all available signals and their types, making it easier for developers to understand what properties are available on the returned object. This follows the pattern established by other TanStack adapters that export their result types. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add Angular example to live-queries.md showing injectLiveQuery usage with modern Angular template syntax (@for, signals) - Add Angular installation instructions to installation.md with compatibility note for v16.0.0+ - Include Angular in framework adapter documentation links alongside React and Vue This ensures Angular gets equal treatment with other framework adapters in the documentation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
No problem happy to continue working on this. I believe the peerDependency should be 17+. I will take a look at this over the weekend as well as the type clarifications. |
Ah I see you updated it to 16. This might be correct I will double check to make sure. |
That's what Claude said 😆
I also pushed something for the types & fiddled with the docs. I think things are ready to go so when you give m a 👍 I'll merge and release! |
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
Fixed two critical issues preventing Angular tests from running: 1. **Angular version mismatch**: @angular/platform-browser v20.3.0 was being pulled in as a peer dependency while using @angular/core v19.2.15, causing import errors for MAX_ANIMATION_TIMEOUT which only exists in Angular v20+. - Added explicit @angular/platform-browser and @angular/compiler v19 dependencies - Ensures all Angular packages use consistent v19 versions for better compatibility 2. **Import path typo**: Fixed incorrect import path from "../../db/tests/utls" to "../../db/tests/utils" in test file Tests now pass successfully: 15 tests passed with 96% coverage 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Thanks for the help! Double checked and 16+ seems to be fine. Everything looks good to go to me 👍 |
Ok great, off it goes! Are you on social medias? I'll tweet it out when it's released and credit you (if you'd like). |
Ah I appreciate it, but I just have a burner for viewing content and I don't post. Was considering starting a real account focused on software but haven't gotten around to it. I'll give you a follow when I do. You can link my GitHub if you'd like. Trying to get into more open-source work in the future so it should be more active than it has been in the past. |
Great, I'll post a link to your GitHub. Thanks again! |
Uh oh!
There was an error while loading. Please reload this page.