Skip to content

Commit 0a88e7b

Browse files
committed
feat(change detection): export SimpleChange
Closes angular#4337
1 parent 711ab6d commit 0a88e7b

File tree

8 files changed

+19
-10
lines changed

8 files changed

+19
-10
lines changed

modules/angular2/src/core/change_detection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export {
1313
ChangeDetectorRef,
1414

1515
WrappedValue,
16+
SimpleChange,
1617
PipeTransform,
1718
PipeOnDestroy,
1819
IterableDiffers,
@@ -21,5 +22,4 @@ export {
2122
KeyValueDiffers,
2223
KeyValueDiffer,
2324
KeyValueDifferFactory
24-
2525
} from './change_detection/change_detection';

modules/angular2/src/core/change_detection/change_detection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export {ChangeDetectorRef} from './change_detector_ref';
5151
export {IterableDiffers, IterableDiffer, IterableDifferFactory} from './differs/iterable_differs';
5252
export {KeyValueDiffers, KeyValueDiffer, KeyValueDifferFactory} from './differs/keyvalue_differs';
5353
export {PipeTransform, PipeOnDestroy} from './pipe_transform';
54-
export {WrappedValue} from './change_detection_util';
54+
export {WrappedValue, SimpleChange} from './change_detection_util';
5555

5656
/**
5757
* Structural diffing for `Object`s and `Map`s.

modules/angular2/src/core/compiler/interfaces.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {StringMap, MapWrapper} from 'angular2/src/core/facade/collection';
2+
import {SimpleChange} from 'angular2/src/core/change_detection/change_detection_util';
23

34
export enum LifecycleHooks {
45
OnInit,
@@ -60,7 +61,7 @@ export var LIFECYCLE_HOOKS_VALUES = [
6061
* }
6162
* ```
6263
*/
63-
export interface OnChanges { onChanges(changes: StringMap<string, any>); }
64+
export interface OnChanges { onChanges(changes: StringMap<string, SimpleChange>); }
6465

6566
/**
6667
* Notify a directive when it has been checked the first time.

modules/angular2/src/core/forms/directives/ng_control_name.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {CONST_EXPR} from 'angular2/src/core/facade/lang';
22
import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async';
33
import {StringMap} from 'angular2/src/core/facade/collection';
44
import {OnChanges, OnDestroy} from 'angular2/lifecycle_hooks';
5+
import {SimpleChange} from 'angular2/src/core/change_detection';
56
import {Query, Directive} from 'angular2/src/core/metadata';
67
import {forwardRef, Host, SkipSelf, Binding, Inject, Optional} from 'angular2/src/core/di';
78

@@ -93,7 +94,7 @@ export class NgControlName extends NgControl implements OnChanges,
9394
this.validators = validators;
9495
}
9596

96-
onChanges(changes: StringMap<string, any>) {
97+
onChanges(changes: StringMap<string, SimpleChange>) {
9798
if (!this._added) {
9899
this.formDirective.addControl(this);
99100
this._added = true;

modules/angular2/src/core/forms/directives/ng_form_control.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {CONST_EXPR} from 'angular2/src/core/facade/lang';
22
import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async';
33
import {OnChanges} from 'angular2/lifecycle_hooks';
4+
import {SimpleChange} from 'angular2/src/core/change_detection';
45
import {Query, Directive} from 'angular2/src/core/metadata';
56
import {forwardRef, Binding, Inject, Optional} from 'angular2/src/core/di';
67
import {NgControl} from './ng_control';
@@ -80,7 +81,7 @@ export class NgFormControl extends NgControl implements OnChanges {
8081
this.validators = validators;
8182
}
8283

83-
onChanges(changes: StringMap<string, any>): void {
84+
onChanges(changes: StringMap<string, SimpleChange>): void {
8485
if (!this._added) {
8586
setUpControl(this.form, this);
8687
this.form.updateValidity();

modules/angular2/src/core/forms/directives/ng_model.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import {CONST_EXPR} from 'angular2/src/core/facade/lang';
22
import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async';
3-
43
import {OnChanges} from 'angular2/lifecycle_hooks';
5-
4+
import {SimpleChange} from 'angular2/src/core/change_detection';
65
import {Query, Directive} from 'angular2/src/core/metadata';
76
import {forwardRef, Binding, Inject, Optional} from 'angular2/src/core/di';
87
import {NgControl} from './ng_control';
@@ -53,7 +52,7 @@ export class NgModel extends NgControl implements OnChanges {
5352
this.validators = validators;
5453
}
5554

56-
onChanges(changes: StringMap<string, any>) {
55+
onChanges(changes: StringMap<string, SimpleChange>) {
5756
if (!this._added) {
5857
setUpControl(this._control, this);
5958
this._control.updateValidity();

modules/angular2/test/compiler/runtime_metadata_spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import {
2929
AfterContentInit,
3030
AfterContentChecked,
3131
AfterViewInit,
32-
AfterViewChecked
32+
AfterViewChecked,
33+
SimpleChange
3334
} from 'angular2/core';
3435

3536
import {TEST_BINDINGS} from './test_bindings';
@@ -115,7 +116,7 @@ class DirectiveWithoutModuleId {
115116
class ComponentWithEverything implements OnChanges,
116117
OnInit, DoCheck, OnDestroy, AfterContentInit, AfterContentChecked, AfterViewInit,
117118
AfterViewChecked {
118-
onChanges(changes: StringMap<string, any>): void {}
119+
onChanges(changes: StringMap<string, SimpleChange>): void {}
119120
onInit(): void {}
120121
doCheck(): void {}
121122
onDestroy(): void {}

modules/angular2/test/public_api_spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,12 @@ var NG_API = [
961961
'SlicePipe',
962962
'SlicePipe.supports()',
963963
'SlicePipe.transform()',
964+
'SimpleChange',
965+
'SimpleChange.currentValue',
966+
'SimpleChange.currentValue=',
967+
'SimpleChange.previousValue',
968+
'SimpleChange.previousValue=',
969+
'SimpleChange.isFirstChange()',
964970
'TemplateRef',
965971
'TemplateRef.elementRef',
966972
'TemplateRef.elementRef=',

0 commit comments

Comments
 (0)