-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathllms.txt
More file actions
72 lines (56 loc) · 1.86 KB
/
llms.txt
File metadata and controls
72 lines (56 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# ziflux — Instructions for AI agents
When generating code for a ziflux project, follow this pattern exactly:
## Creating a new domain (e.g. "product")
**Step 1** — Create `product.api.ts`:
```typescript
@Injectable({ providedIn: 'root' })
export class ProductApi {
readonly cache = new DataCache()
readonly #http = inject(HttpClient)
getAll$(): Observable<Product[]> {
return this.#http.get<Product[]>('/products')
}
getById$(id: string): Observable<Product> {
return this.#http.get<Product>(`/products/${id}`)
}
create$(body: CreateProduct): Observable<Product> {
return this.#http.post<Product>('/products', body)
}
}
```
**Step 2** — Create `product-list.store.ts`:
```typescript
@Injectable()
export class ProductListStore {
readonly #api = inject(ProductApi)
readonly products = cachedResource({
cache: this.#api.cache,
cacheKey: ['product', 'list'],
loader: () => this.#api.getAll$(),
})
readonly createProduct = cachedMutation({
cache: this.#api.cache,
mutationFn: (body: CreateProduct) => this.#api.create$(body),
invalidateKeys: () => [['product', 'list']],
})
readonly isAnythingLoading = anyLoading(
this.products.isLoading,
this.createProduct.isPending,
)
}
```
**Step 3** — Use in component:
```typescript
@Component({ providers: [ProductListStore] })
export class ProductListComponent {
readonly store = inject(ProductListStore)
}
```
## What an agent must NOT do
- Inject an API service directly in a component
- Put `DataCache` inside a store
- Call HTTP methods from a store
- Skip the API layer and fetch directly in `cachedResource`'s loader
- Create a new `DataCache` per store (use the one from the API service)
- Write manual loading/error signal boilerplate — use `cachedMutation()` instead
- Invalidate cache manually inside a store — use `cachedMutation`'s `invalidateKeys`