Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnPush Change detection logic should not markAsCheckOnce when status is Detached #9720

Closed
shlomiassaf opened this issue Jun 30, 2016 · 3 comments

Comments

@shlomiassaf
Copy link
Contributor

commented Jun 30, 2016

I'm submitting a ... (check one with "x")

[x] bug report
[x] feature request

Current behavior
When change detection strategy is set to OnPush you can not detach it.
Plunker: http://plnkr.co/edit/H4NZGy?p=preview

Expected/desired behavior
OnPush should respect detach().

What is the motivation / use case for changing the behavior?
Following @bennadel blog post I was wondering why this happens.
I found that the detectChangesInternal() implementation in the view factory created by the code generator call markAsCheckOnce() on every change detection pass.

 if (changed) { self._appEl_11.componentView.markAsCheckOnce(); }

The code gen should only call markAsCheckOnce() when cdMode !== ChangeDetectionStrategy.Detached

A workaround would be to call changeDetectionRef.detach() inside ngOnChanges life cycle hook, this will revert the state back.

  • Angular version: 2.0.0-rc.3
@shlomiassaf

This comment has been minimized.

Copy link
Contributor Author

commented Jul 6, 2016

@vsavkin Is this a bug? feature?

Will it go into angular? if so roughly when?

Some labels are missing :)

@tbosch

This comment has been minimized.

Copy link
Contributor

commented Apr 27, 2017

@tbosch tbosch self-assigned this Apr 27, 2017
tbosch added a commit to tbosch/angular that referenced this issue Apr 27, 2017
tbosch added a commit to tbosch/angular that referenced this issue Apr 28, 2017
tbosch added a commit to tbosch/angular that referenced this issue Apr 28, 2017
@mhevery mhevery closed this in aa8bba4 Apr 28, 2017
@tbosch tbosch moved this from Prio_col0 to Done in Compiler Apr 29, 2017
asnowwolf added a commit to asnowwolf/angular that referenced this issue Aug 11, 2017
juleskremer added a commit to juleskremer/angular that referenced this issue Aug 28, 2017
@tbosch tbosch removed this from Done in Compiler Oct 3, 2017
@angular-automatic-lock-bot

This comment has been minimized.

Copy link

commented Sep 11, 2019

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants
You can’t perform that action at this time.