Wzorce projektowe¶
Smart vs Dumb Components¶
Smart (Container): - Komunikacja ze store - Dispatch actions - Business logic
Dumb (Presentational): - @Input/@Output - Tylko UI - Reużywalne
Observable Patterns¶
// Unsubscribe pattern
private destroy$ = new Subject<void>();
ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
// Użycie
this.data$.pipe(
takeUntil(this.destroy$)
).subscribe();
Abstract Base Classes¶
export abstract class AbstractApiService<T> {
abstract getAll(): Observable<T[]>;
abstract getById(id: string): Observable<T>;
}