← Vissza a katalógushoz

Skill · 1.0.0 verzió

Angular-komponensek és függőségek

Elválasztja a megjelenítést, vezérlést és szolgáltatásokat, egyértelmű hatókörrel és erőforrás-élettartammal.

angular-components-di

Nézd meg, miben segít

Mikor hasznos?

Akkor használd, ha túl nagy komponensek vagy többször létrejövő szolgáltatások zavarják az állapotkezelést.

Miben segít neked?

  • Típusos bemeneteket és eseményeket tervez üzleti mellékhatások nélküli sablonokhoz.
  • Tudatosan választ alkalmazás-, útvonal- vagy komponensszintű szolgáltatáspéldányt.
  • Megszünteti a szükségtelen időzítőket, feliratkozásokat és eseményfigyelőket.

Például ezt kérheted

Bontsd fel a rendelési képernyőt, és mutasd meg, mely szolgáltatások éljenek tovább navigálás után. Lépj el egy nem mentett rendelésről, majd térj vissza. Ellenőrizd a szándékosan megőrzött piszkozatot és a megszűnt komponens eseményfigyelőinek felszabadítását.

Részletes dokumentáció

Itt a skill eredeti útmutatóját, példáit és ellenőrzési szempontjait olvashatod az eredeti nyelven.

Részletek…Összecsukás

Angular Components & Dependency Injection

Keep components focused on presentation and user interaction, and organize services and providers with explicit boundaries, injector scopes and lifetimes.

1. Component boundaries and inputs/outputs

  • Split smart/container components (which coordinate routes, services and state) from presentational components (which receive inputs and emit outputs).
  • Match the project's input/output style (input() / output() / model() in modern Angular, or @Input() / @Output() where standard); keep inputs immutable from the child's perspective.
  • Never put business side effects, HTTP calls or heavy computation inside template expressions or property getters called on every change-detection cycle; use computed(), pure pipes or derived streams instead.
  • Follow the project's ChangeDetectionStrategy (OnPush where used); never paper over stale views with arbitrary ChangeDetectorRef.detectChanges() without finding why the input reference, signal or async pipe did not notify Angular.

2. Dependency injection and provider scopes

  • Follow the project's DI style (inject() function vs constructor injection) consistently.
  • Choose the narrowest appropriate provider scope and understand instance lifetime:
    • providedIn: 'root': app-wide singletons (auth, API clients, global caches) that live for the application's lifetime; ensure they do not retain stale feature state across route or user changes.
    • Route providers: [...]: feature-scoped services shared across a route subtree and destroyed when leaving the route.
    • Component providers: [...] / viewProviders: [...]: per-component instance state (complex form coordinators, local facade services) destroyed with the component (ngOnDestroy / DestroyRef).
  • Never accidentally provide a stateful singleton service in both root and a component's providers array unless a separate per-component instance is deliberate.
  • Use InjectionToken<T> for configuration objects, environment values and abstract contracts.

3. Lifecycle and resource cleanup

  • Register cleanup for timers, manual subscriptions, DOM listeners and third-party instances using DestroyRef.onDestroy(...), takeUntilDestroyed(), or ngOnDestroy().

Before you finish

  • Components have a single clear responsibility and typed inputs/outputs.
  • No side effects or expensive calculations inside template expressions or getters.
  • Every service is provided at the intended scope (root, route, or component) without accidental duplicate instances.
  • Component and service resources clean up on destroy.

Csomagban lévő fájlok 2

  • LICENSE.txt
  • SKILL.md

A skillcsomag bemutatása

angular-components-di

angular-components-di: Jól karbantartható Angular funkciókat készít világos komponenshatárokkal, reaktív állapottal, űrlapokkal és tesztelt migrációkkal.

Részletek…Összecsukás

angular-components-di

angular-components-di: Jól karbantartható Angular funkciókat készít világos komponenshatárokkal, reaktív állapottal, űrlapokkal és tesztelt migrációkkal.

A teljes skillt és a hozzá tartozó fájlokat tartalmazza (2 fájl). Az alábbi eredeti leírás rögzíti a pontos alkalmazási területét.

A skill eredeti leírása (a forrás nyelvén)

Use when designing or implementing Angular components, directives, pipes, services, dependency injection providers and hierarchical injector scopes.

Telepítsd a skillt, nézd át a forrását és a megbízhatósági beállításait, majd engedélyezd a megfelelő projektben vagy ügynöknél.

Előfeltételek

  • A számítógépedre telepített Orqestria.