1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-30 16:23:53 +00:00

Add the referenced angular.md file

This commit is contained in:
Anders Åberg
2026-01-15 13:01:34 +01:00
parent 4d9d1ee4e8
commit 65df9ac9ae

45
.claude/ANGULAR.md Normal file
View File

@@ -0,0 +1,45 @@
# Angular patterns
## Observable Data Services (ADR-0003):
```typescript
// Service exposes Observable streams
private _data$ = new BehaviorSubject<Data[]>([]);
readonly data$ = this._data$.asObservable();
// Component uses async pipe
data$ = this.dataService.data$;
// Template: <div *ngFor="let item of data$ | async">
```
## Subscription cleanup (required for explicit subscriptions)
```typescript
constructor() {
this.observable$.pipe(takeUntilDestroyed()).subscribe(...);
}
```
## Signals
Use Angular Signals only in components and presentational services. Use RxJS for cross-client services and complex reactive workflows.
## No TypeScript Enums (ADR-0025):
```typescript
// ✅ Correct
export const CipherType = Object.freeze({
Login: 1,
SecureNote: 2,
} as const);
export type CipherType = (typeof CipherType)[keyof typeof CipherType];
// ❌ Wrong - don't add new enums
enum CipherType {
Login = 1,
}
```
## Component Change Detection
Use `OnPush` change detection strategy for all components.