Skip to content

Proposal: smarter change detection #22646

@anjmao

Description

@anjmao

I created sad-hover component which is really sad at the moment. Here is stackblitz https://stackblitz.com/edit/angular-sad-hover?file=app%2Fapp.component.ts Open developer tools to see console output.

Problem:

  1. I have isolated sad-hover component which uses OnPush.
  2. Inside it I use (mouseleave) and (mouseover) and I don't want to trigger my whole app change detection to run.
  3. This component is used in parent sad-cat component, and sad-cat is used on root app component.
  4. It turns out that zone is still grabbing these events and triggers parent component and root to update.

Solution:
Allow to have truly isolate component so everything that I make inside will stay inside, but I'm still be able to notify parent components about changes by using @Output();
One solution could be to allow inject zone and say than I don't want to trigger any parent's component's CD.

class MyIsolatedCmp {
   constructor(zone: NgZone) {
      zone.SkipParent();
   }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimecore: change detectionfeatureLabel used to distinguish feature request from other issuesfeature: under considerationFeature request for which voting has completed and the request is now under consideration

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions