# Angular Best Practices - FikoYT

## 🎯 Component Pattern

```typescript
@Component({
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class BaseComponent {
  // Inject API
  readonly CD = inject(ChangeDetectorRef);
  readonly FikoYT = inject(FikoYTService);

  // Subscription cleanup
  subs: Subscription[] = [];

  ngOnDestroy() {
    this.subs.forEach(s => s.unsubscribe());
  }
}
```

## 🔄 State Management

- **Signals:** Yeni reactive pattern
- **Services:** Shared state
- **RxJS:** Async operations
- **OnPush:** Performance

## 📦 Dependency Injection

```typescript
// Service injection
@Injectable({ providedIn: 'root' })
export class MyService {
  private data = signal<any[]>([]);

  getData() {
    return this.data.asReadonly();
  }
}

// Component usage
export class MyComponent {
  data = inject(MyService).getData();
}
```

## 🎨 Best Practices

- **TypeScript:** Strict mode
- **Lazy loading:** Route level
- **TrackBy:** *ngFor optimizasyonu
- **Pure pipes:** Performance
- **Detach:** Manuel CD

---
2025-11-06