Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/angular-db-initial-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tanstack/angular-db": minor
---

Add @tanstack/angular-db package with Angular integration for TanStack DB
22 changes: 22 additions & 0 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@
"to": "framework/svelte/adapter"
}
]
},
{
"label": "angular",
"children": [
{
"label": "Angular Adapter",
"to": "framework/angular/adapter"
}
]
}
]
},
Expand Down Expand Up @@ -198,6 +207,19 @@
"to": "framework/vue/reference/interfaces/uselivequeryreturnwithcollection"
}
]
},
{
"label": "angular",
"children": [
{
"label": "Angular Functions",
"to": "framework/angular/reference/index"
},
{
"label": "injectLiveQuery",
"to": "framework/angular/reference/functions/injectlivequery"
}
]
}
]
}
Expand Down
16 changes: 16 additions & 0 deletions docs/framework/angular/adapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: TanStack DB Angular Adapter
id: adapter
---

## Installation

```sh
npm install @tanstack/angular-db
```

## Angular inject function

See the [Angular Functions Reference](../reference/index.md) to see the full list of functions available in the Angular Adapter.

## Basic Usage
25 changes: 24 additions & 1 deletion docs/guides/live-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,30 @@ function UserList() {
}
```

For more details on framework integration, see the [React](../../framework/react/adapter) and [Vue](../../framework/vue/adapter) adapter documentation.
In Angular, you can use the `injectLiveQuery` function:

```typescript
import { Component } from '@angular/core'
import { injectLiveQuery } from '@tanstack/angular-db'

@Component({
selector: 'user-list',
template: `
@for (user of activeUsers.data(); track user.id) {
<li>{{ user.name }}</li>
}
`
})
export class UserListComponent {
activeUsers = injectLiveQuery((q) =>
q
.from({ user: usersCollection })
.where(({ user }) => eq(user.active, true))
)
}
```

For more details on framework integration, see the [React](../../framework/react/adapter), [Vue](../../framework/vue/adapter), and [Angular](../../framework/angular/adapter) adapter documentation.

## From Clause

Expand Down
8 changes: 8 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ npm install @tanstack/vue-db

TanStack DB is compatible with Vue v3.3.0+

## Angular

```sh
npm install @tanstack/angular-db
```

TanStack DB is compatible with Angular v16.0.0+

## Vanilla JS

```sh
Expand Down
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default [
`**/.output/**`,
`**/.nitro/**`,
`**/traildepot/**`,
`examples/angular/**`,
],
},
{
Expand Down
17 changes: 17 additions & 0 deletions examples/angular/todos/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single
ij_typescript_use_double_quotes = false

[*.md]
max_line_length = off
trim_trailing_whitespace = false
42 changes: 42 additions & 0 deletions examples/angular/todos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db
6 changes: 6 additions & 0 deletions examples/angular/todos/.postcssrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugins": {
"tailwindcss": {},
"autoprefixer": {}
}
}
59 changes: 59 additions & 0 deletions examples/angular/todos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Todos

This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 20.1.6.

## Development server

To start a local development server, run:

```bash
ng serve
```

Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.

## Code scaffolding

Angular CLI includes powerful code scaffolding tools. To generate a new component, run:

```bash
ng generate component component-name
```

For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:

```bash
ng generate --help
```

## Building

To build the project run:

```bash
ng build
```

This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.

## Running unit tests

To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:

```bash
ng test
```

## Running end-to-end tests

For end-to-end (e2e) testing, run:

```bash
ng e2e
```

Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.

## Additional Resources

For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
87 changes: 87 additions & 0 deletions examples/angular/todos/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"cli": {
"packageManager": "npm",
"analytics": false
},
"newProjectRoot": "projects",
"projects": {
"todos": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular/build:application",
"options": {
"browser": "src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.app.json",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": ["src/styles.css"]
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kB",
"maximumError": "1MB"
},
{
"type": "anyComponentStyle",
"maximumWarning": "4kB",
"maximumError": "8kB"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular/build:dev-server",
"configurations": {
"production": {
"buildTarget": "todos:build:production"
},
"development": {
"buildTarget": "todos:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular/build:extract-i18n"
},
"test": {
"builder": "@angular/build:karma",
"options": {
"polyfills": ["zone.js", "zone.js/testing"],
"tsConfig": "tsconfig.spec.json",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": ["src/styles.css"]
}
}
}
}
}
}
53 changes: 53 additions & 0 deletions examples/angular/todos/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "todos",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"prettier": {
"printWidth": 100,
"singleQuote": true,
"overrides": [
{
"files": "*.html",
"options": {
"parser": "angular"
}
}
]
},
"private": true,
"dependencies": {
"@angular/common": "^20.1.0",
"@angular/compiler": "^20.1.0",
"@angular/core": "^20.1.0",
"@angular/forms": "^20.1.0",
"@angular/platform-browser": "^20.1.0",
"@angular/router": "^20.1.0",
"@tanstack/angular-db": "workspace:*",
"@tanstack/db": "workspace:*",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular/build": "^20.1.6",
"@angular/cli": "^20.1.6",
"@angular/compiler-cli": "^20.1.0",
"@types/jasmine": "~5.1.0",
"autoprefixer": "^10.4.14",
"jasmine-core": "~5.8.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"postcss": "^8.5.6",
"tailwindcss": "^3.4.17",
"typescript": "~5.8.2"
}
}
Binary file added examples/angular/todos/public/favicon.ico
Binary file not shown.
Loading
Loading