feat(change detection): export SimpleChange

Closes #4337
This commit is contained in:
Victor Berchet 2015-09-23 11:43:31 -07:00
parent 711ab6d573
commit 0a88e7b736
8 changed files with 19 additions and 10 deletions

View File

@ -13,6 +13,7 @@ export {
ChangeDetectorRef, ChangeDetectorRef,
WrappedValue, WrappedValue,
SimpleChange,
PipeTransform, PipeTransform,
PipeOnDestroy, PipeOnDestroy,
IterableDiffers, IterableDiffers,
@ -21,5 +22,4 @@ export {
KeyValueDiffers, KeyValueDiffers,
KeyValueDiffer, KeyValueDiffer,
KeyValueDifferFactory KeyValueDifferFactory
} from './change_detection/change_detection'; } from './change_detection/change_detection';

View File

@ -51,7 +51,7 @@ export {ChangeDetectorRef} from './change_detector_ref';
export {IterableDiffers, IterableDiffer, IterableDifferFactory} from './differs/iterable_differs'; export {IterableDiffers, IterableDiffer, IterableDifferFactory} from './differs/iterable_differs';
export {KeyValueDiffers, KeyValueDiffer, KeyValueDifferFactory} from './differs/keyvalue_differs'; export {KeyValueDiffers, KeyValueDiffer, KeyValueDifferFactory} from './differs/keyvalue_differs';
export {PipeTransform, PipeOnDestroy} from './pipe_transform'; export {PipeTransform, PipeOnDestroy} from './pipe_transform';
export {WrappedValue} from './change_detection_util'; export {WrappedValue, SimpleChange} from './change_detection_util';
/** /**
* Structural diffing for `Object`s and `Map`s. * Structural diffing for `Object`s and `Map`s.

View File

@ -1,4 +1,5 @@
import {StringMap, MapWrapper} from 'angular2/src/core/facade/collection'; import {StringMap, MapWrapper} from 'angular2/src/core/facade/collection';
import {SimpleChange} from 'angular2/src/core/change_detection/change_detection_util';
export enum LifecycleHooks { export enum LifecycleHooks {
OnInit, OnInit,
@ -60,7 +61,7 @@ export var LIFECYCLE_HOOKS_VALUES = [
* } * }
* ``` * ```
*/ */
export interface OnChanges { onChanges(changes: StringMap<string, any>); } export interface OnChanges { onChanges(changes: StringMap<string, SimpleChange>); }
/** /**
* Notify a directive when it has been checked the first time. * Notify a directive when it has been checked the first time.

View File

@ -2,6 +2,7 @@ import {CONST_EXPR} from 'angular2/src/core/facade/lang';
import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async'; import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async';
import {StringMap} from 'angular2/src/core/facade/collection'; import {StringMap} from 'angular2/src/core/facade/collection';
import {OnChanges, OnDestroy} from 'angular2/lifecycle_hooks'; import {OnChanges, OnDestroy} from 'angular2/lifecycle_hooks';
import {SimpleChange} from 'angular2/src/core/change_detection';
import {Query, Directive} from 'angular2/src/core/metadata'; import {Query, Directive} from 'angular2/src/core/metadata';
import {forwardRef, Host, SkipSelf, Binding, Inject, Optional} from 'angular2/src/core/di'; import {forwardRef, Host, SkipSelf, Binding, Inject, Optional} from 'angular2/src/core/di';
@ -93,7 +94,7 @@ export class NgControlName extends NgControl implements OnChanges,
this.validators = validators; this.validators = validators;
} }
onChanges(changes: StringMap<string, any>) { onChanges(changes: StringMap<string, SimpleChange>) {
if (!this._added) { if (!this._added) {
this.formDirective.addControl(this); this.formDirective.addControl(this);
this._added = true; this._added = true;

View File

@ -1,6 +1,7 @@
import {CONST_EXPR} from 'angular2/src/core/facade/lang'; import {CONST_EXPR} from 'angular2/src/core/facade/lang';
import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async'; import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async';
import {OnChanges} from 'angular2/lifecycle_hooks'; import {OnChanges} from 'angular2/lifecycle_hooks';
import {SimpleChange} from 'angular2/src/core/change_detection';
import {Query, Directive} from 'angular2/src/core/metadata'; import {Query, Directive} from 'angular2/src/core/metadata';
import {forwardRef, Binding, Inject, Optional} from 'angular2/src/core/di'; import {forwardRef, Binding, Inject, Optional} from 'angular2/src/core/di';
import {NgControl} from './ng_control'; import {NgControl} from './ng_control';
@ -80,7 +81,7 @@ export class NgFormControl extends NgControl implements OnChanges {
this.validators = validators; this.validators = validators;
} }
onChanges(changes: StringMap<string, any>): void { onChanges(changes: StringMap<string, SimpleChange>): void {
if (!this._added) { if (!this._added) {
setUpControl(this.form, this); setUpControl(this.form, this);
this.form.updateValidity(); this.form.updateValidity();

View File

@ -1,8 +1,7 @@
import {CONST_EXPR} from 'angular2/src/core/facade/lang'; import {CONST_EXPR} from 'angular2/src/core/facade/lang';
import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async'; import {EventEmitter, ObservableWrapper} from 'angular2/src/core/facade/async';
import {OnChanges} from 'angular2/lifecycle_hooks'; import {OnChanges} from 'angular2/lifecycle_hooks';
import {SimpleChange} from 'angular2/src/core/change_detection';
import {Query, Directive} from 'angular2/src/core/metadata'; import {Query, Directive} from 'angular2/src/core/metadata';
import {forwardRef, Binding, Inject, Optional} from 'angular2/src/core/di'; import {forwardRef, Binding, Inject, Optional} from 'angular2/src/core/di';
import {NgControl} from './ng_control'; import {NgControl} from './ng_control';
@ -53,7 +52,7 @@ export class NgModel extends NgControl implements OnChanges {
this.validators = validators; this.validators = validators;
} }
onChanges(changes: StringMap<string, any>) { onChanges(changes: StringMap<string, SimpleChange>) {
if (!this._added) { if (!this._added) {
setUpControl(this._control, this); setUpControl(this._control, this);
this._control.updateValidity(); this._control.updateValidity();

View File

@ -29,7 +29,8 @@ import {
AfterContentInit, AfterContentInit,
AfterContentChecked, AfterContentChecked,
AfterViewInit, AfterViewInit,
AfterViewChecked AfterViewChecked,
SimpleChange
} from 'angular2/core'; } from 'angular2/core';
import {TEST_BINDINGS} from './test_bindings'; import {TEST_BINDINGS} from './test_bindings';
@ -115,7 +116,7 @@ class DirectiveWithoutModuleId {
class ComponentWithEverything implements OnChanges, class ComponentWithEverything implements OnChanges,
OnInit, DoCheck, OnDestroy, AfterContentInit, AfterContentChecked, AfterViewInit, OnInit, DoCheck, OnDestroy, AfterContentInit, AfterContentChecked, AfterViewInit,
AfterViewChecked { AfterViewChecked {
onChanges(changes: StringMap<string, any>): void {} onChanges(changes: StringMap<string, SimpleChange>): void {}
onInit(): void {} onInit(): void {}
doCheck(): void {} doCheck(): void {}
onDestroy(): void {} onDestroy(): void {}

View File

@ -961,6 +961,12 @@ var NG_API = [
'SlicePipe', 'SlicePipe',
'SlicePipe.supports()', 'SlicePipe.supports()',
'SlicePipe.transform()', 'SlicePipe.transform()',
'SimpleChange',
'SimpleChange.currentValue',
'SimpleChange.currentValue=',
'SimpleChange.previousValue',
'SimpleChange.previousValue=',
'SimpleChange.isFirstChange()',
'TemplateRef', 'TemplateRef',
'TemplateRef.elementRef', 'TemplateRef.elementRef',
'TemplateRef.elementRef=', 'TemplateRef.elementRef=',