-
Notifications
You must be signed in to change notification settings - Fork 6.8k
build: add toggle for OnPush change detection in demo app #3675
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
build: add toggle for OnPush change detection in demo app #3675
Conversation
src/demo-app/demo-app/demo-app.ts
Outdated
@@ -17,8 +26,12 @@ export class Home {} | |||
templateUrl: 'demo-app.html', | |||
styleUrls: ['demo-app.css'], | |||
encapsulation: ViewEncapsulation.None, | |||
changeDetection: isPushChangeDetection ? | |||
ChangeDetectionStrategy.OnPush : | |||
ChangeDetectionStrategy.Default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a thought, why don't you store it that way? Looks a bit more clear to me.
let changeDetection = ChangeDetectionStrategy.Default;
try {
if (localStorage.getItem(changeDetectionKey) {
changeDetection = ChangeDetectionStrategy.OnPush;
}
} catch (e) {
console.error(e);
}
@Component({
templateUrl: 'XXXX.html',
changeDetection: changeDetection
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the boolean is easier for displaying in the UI. AFAIK the detection strategies map to numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Yeah I initially thought that setItem(key, changeDetectionStrategy)
would work, but it maps to integers.
src/demo-app/demo-app/demo-app.ts
Outdated
@@ -17,8 +26,12 @@ export class Home {} | |||
templateUrl: 'demo-app.html', | |||
styleUrls: ['demo-app.css'], | |||
encapsulation: ViewEncapsulation.None, | |||
changeDetection: isPushChangeDetection ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will work with AoT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to work on the CI which we run against the demo app.
79a63f8
to
ff97b23
Compare
Re-did this one to avoid AoT issues @jelbourn. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Adds a toggle for enabling `OnPush` change detection in the demo app. This should make it easier to test out components with the different change detection strategies.
ff97b23
to
c5a46e7
Compare
Done. Also needed a rebase. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Adds a toggle for enabling
OnPush
change detection in the demo app. This should make it easier to test out components against the different change detection strategies.