-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into derived-diamond-problem
- Loading branch information
Showing
35 changed files
with
5,469 additions
and
451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
distribute-on: | ||
small-changeset: 8 linux-medium-js | ||
medium-changeset: 10 linux-medium-js | ||
large-changeset: 12 linux-medium-js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
title: Quick Start | ||
id: quick-start | ||
--- | ||
|
||
The basic angular app example to get started with the Tanstack angular-store. | ||
|
||
**app.component.ts** | ||
```html | ||
<h1>How many of your friends like cats or dogs?</h1> | ||
<p>Press one of the buttons to add a counter of how many of your friends like cats or dogs</p> | ||
<app-increment animal="dogs" /> | ||
<app-display animal="dogs" /> | ||
<app-increment animal="cats" /> | ||
<app-display animal="cats" /> | ||
``` | ||
|
||
**store.ts** | ||
```js | ||
import { Store } from '@tanstack/store'; | ||
|
||
// You can use @tanstack/store outside of App components too! | ||
export const store = new Store({ | ||
dogs: 0, | ||
cats: 0, | ||
}); | ||
|
||
export function updateState(animal: 'dogs' | 'cats') { | ||
store.setState((state) => { | ||
return { | ||
...state, | ||
[animal]: state[animal] + 1, | ||
}; | ||
}); | ||
} | ||
``` | ||
|
||
**display.component.ts** | ||
```typescript | ||
import { injectStore } from '@tanstack/angular-store'; | ||
import { store } from './store'; | ||
|
||
@Component({ | ||
selector: 'app-display', | ||
template: ` | ||
<!-- This will only re-render when animal changes. If an unrelated store property changes, it won't re-render --> | ||
<div>{{ animal() }}: {{ count() }}</div> | ||
`, | ||
standalone: true | ||
}) | ||
export class Display { | ||
animal = input.required<string>(); | ||
count = injectStore(store, (state) => state[this.animal()]); | ||
} | ||
``` | ||
|
||
**increment.component.ts** | ||
```typescript | ||
import { injectStore } from '@tanstack/angular-store'; | ||
import { store, updateState } from './store'; | ||
|
||
@Component({ | ||
selector: 'app-increment', | ||
template: ` | ||
<button (click)="updateState(animal())">My Friend Likes {{ animal() }}</button> | ||
`, | ||
standalone: true | ||
}) | ||
export class Increment { | ||
animal = input.required<string>(); | ||
updateState = injectStore(store, updateState); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: Inject Store | ||
id: injectStore | ||
--- | ||
|
||
Please see [/packages/angular-store/src/index.ts](https://github.com/tanstack/store/tree/main/packages/angular-store/src/index.ts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/knip@4/schema.json", | ||
"workspaces": { | ||
"packages/angular-store": { | ||
"ignoreDependencies": ["@angular/compiler-cli"] | ||
}, | ||
"packages/vue-store": { | ||
"ignoreDependencies": ["vue2", "vue2.7"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.