Skip to content

Commit

Permalink
refactor(ngdart)!: rename and remove deprecated values from ChangeDet…
Browse files Browse the repository at this point in the history
…ectionStrategy and APP_ID (#41)

All values provided by the static `ChangeDetectionStrategy` class are now members of the `ChangeDetectionStrategy` enum. The `default` change detection strategy is now removed in favor of `checkAlways` since they have identical behaviors.

In addition, the `APP_ID` injection token is renamed to `appId` to conform to the idiomatic Dart language style.
  • Loading branch information
ykmnkmi authored Mar 16, 2023
1 parent 063c91e commit 3c5523a
Show file tree
Hide file tree
Showing 34 changed files with 150 additions and 405 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void main() {
@Component(
selector: 'test',
template: '',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class OnPushComponent {}
""");
Expand Down
16 changes: 8 additions & 8 deletions _tests/test/compiler_integration/on_push_validation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ void main() {
<default></default>
</div>
''',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
directives: [DefaultComponent],
)
class TestComponent {}
""", warnings: [
allOf([
contains('<default>'),
contains(
'"DefaultComponent" doesn\'t use "ChangeDetectionStrategy.OnPush"',
'"DefaultComponent" doesn\'t use "ChangeDetectionStrategy.onPush"',
),
]),
]);
Expand All @@ -56,7 +56,7 @@ void main() {
<default @skipOnPushValidation></default>
</div>
''',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
directives: [DefaultComponent],
)
class TestComponent {}
Expand All @@ -73,7 +73,7 @@ void main() {
template: '''
<div @skipOnPushValidation></div>
''',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class TestComponent {}
""", errors: [
Expand All @@ -91,7 +91,7 @@ void main() {
@Component(
selector: 'on-push',
template: '',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class OnPushComponent {}
Expand All @@ -101,15 +101,15 @@ void main() {
<on-push @skipOnPushValidation></on-push>
''',
directives: [OnPushComponent],
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class TestComponent {}
""", errors: [
allOf([
contains('@skipOnPushValidation'),
contains(
'Can only be applied to a component using '
'"ChangeDetectionStrategy.Default"',
'"ChangeDetectionStrategy.checkAlways"',
),
]),
]);
Expand Down Expand Up @@ -138,7 +138,7 @@ void main() {
contains('@skipOnPushValidation'),
contains(
'Can only be used in the template of a component using '
'"ChangeDetectionStrategy.OnPush"',
'"ChangeDetectionStrategy.onPush"',
),
]),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class DefaultComponent {
@Component(
selector: 'on-push-container',
template: '<template #container></template>',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class OnPushContainerComponent {
@Input()
Expand Down Expand Up @@ -142,7 +142,7 @@ class LoadInOnPush {
</on-push-container>
''',
directives: [OnPushContainerComponent],
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class OnPushAncestorComponent {
@Input()
Expand Down Expand Up @@ -170,7 +170,7 @@ class LoadInOnPushDescendant {
</ng-container>
''',
directives: [NgIf],
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class OnPushEmbeddedContainerComponent {
OnPushEmbeddedContainerComponent(this._changeDetectorRef, this._ngZone);
Expand Down
235 changes: 0 additions & 235 deletions _tests/test/core/change_detection/detached_lifecycle_test.dart

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void main() {
@Component(
selector: 'child',
template: '{{value}}',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class Child {
var value = '';
Expand Down Expand Up @@ -245,7 +245,7 @@ abstract class HasValue {
providers: [
ExistingProvider(HasValue, ChildWithExistingProvider),
],
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class ChildWithExistingProvider implements HasValue {
@override
Expand Down
2 changes: 1 addition & 1 deletion _tests/test/core/change_detection/mark_for_check_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class UsesOnPushComponent {
directives: [
NgIf,
],
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class OnPushComponent {
final ChangeDetectorRef _changeDetector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class TestComponent {
template: '''
<template #template>{{templateText}}</template>
''',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
exportAs: 'templateProducer',
)
class TemplateProducerComponent implements OnInit {
Expand All @@ -149,7 +149,7 @@ class TemplateProducerComponent implements OnInit {
<template #container></template>
<div>{{text}}</div>
''',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class TemplateConsumerComponent implements OnInit {
@ViewChild('container', read: ViewContainerRef)
Expand Down
2 changes: 1 addition & 1 deletion _tests/test/core/linker/component_loader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class DynamicComp extends Lifecycles {
@Component(
selector: 'dynamic-comp',
template: 'Dynamic{{input}}',
changeDetection: ChangeDetectionStrategy.OnPush,
changeDetection: ChangeDetectionStrategy.onPush,
)
class DynamicOnPushComp extends Lifecycles {
DynamicOnPushComp(super.log);
Expand Down
Loading

0 comments on commit 3c5523a

Please sign in to comment.