Skip to content

Commit c83a3f3

Browse files
committed
chore(docs): added more docs for core.ts
1 parent 0906ee8 commit c83a3f3

48 files changed

Lines changed: 414 additions & 180 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

modules/angular2/angular2.ts

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,9 @@ export {commonBootstrap as bootstrap} from 'angular2/src/core/application_common
77
// angular2_exports.ts. Re-exporting from angular2_exports.ts causes systemjs
88
// to resolve imports very very very slowly. See also a similar notice in
99
// bootstrap.ts
10-
export * from 'angular2/annotations';
11-
export * from 'angular2/core';
12-
13-
export {
14-
DehydratedException,
15-
ExpressionChangedAfterItHasBeenChecked,
16-
ChangeDetectionError,
17-
18-
ON_PUSH,
19-
DEFAULT,
20-
21-
ChangeDetectorRef,
22-
23-
Pipes,
24-
WrappedValue,
25-
Pipe,
26-
PipeFactory,
27-
NullPipe,
28-
NullPipeFactory,
29-
defaultPipes,
30-
BasePipe,
31-
32-
Locals
33-
} from './change_detection';
34-
10+
export * from './annotations';
11+
export * from './core';
12+
export * from './change_detection';
3513
export * from './di';
3614
export * from './forms';
3715
export * from './directives';

modules/angular2/angular2_exports.ts

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,6 @@
1-
export * from 'angular2/annotations';
2-
export * from 'angular2/core';
3-
4-
export {
5-
DehydratedException,
6-
ExpressionChangedAfterItHasBeenChecked,
7-
ChangeDetectionError,
8-
9-
ON_PUSH,
10-
DEFAULT,
11-
12-
ChangeDetectorRef,
13-
14-
Pipes,
15-
WrappedValue,
16-
Pipe,
17-
PipeFactory,
18-
NullPipe,
19-
NullPipeFactory,
20-
defaultPipes,
21-
BasePipe,
22-
23-
Locals
24-
} from './change_detection';
25-
1+
export * from './annotations';
2+
export * from './core';
3+
export * from './change_detection';
264
export * from './di';
275
export * from './forms';
286
export * from './directives';

modules/angular2/change_detection.ts

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,33 @@
44
* Change detection enables data binding in Angular.
55
*/
66

7-
export {
8-
ASTWithSource,
9-
AST,
10-
AstTransformer,
11-
AccessMember,
12-
LiteralArray,
13-
ImplicitReceiver
14-
} from './src/change_detection/parser/ast';
15-
16-
export {Lexer} from './src/change_detection/parser/lexer';
17-
export {Parser} from './src/change_detection/parser/parser';
18-
export {Locals} from './src/change_detection/parser/locals';
19-
20-
export {
21-
DehydratedException,
22-
ExpressionChangedAfterItHasBeenChecked,
23-
ChangeDetectionError
24-
} from './src/change_detection/exceptions';
25-
export {
26-
ProtoChangeDetector,
27-
ChangeDetector,
28-
ChangeDispatcher,
29-
ChangeDetection,
30-
ChangeDetectorDefinition
31-
} from './src/change_detection/interfaces';
327
export {
338
CHECK_ONCE,
349
CHECK_ALWAYS,
3510
DETACHED,
3611
CHECKED,
3712
ON_PUSH,
38-
DEFAULT
39-
} from './src/change_detection/constants';
40-
export {DynamicProtoChangeDetector} from './src/change_detection/proto_change_detector';
41-
export {BindingRecord} from './src/change_detection/binding_record';
42-
export {DirectiveIndex, DirectiveRecord} from './src/change_detection/directive_record';
43-
export {DynamicChangeDetector} from './src/change_detection/dynamic_change_detector';
44-
export {ChangeDetectorRef} from './src/change_detection/change_detector_ref';
45-
export {Pipes} from './src/change_detection/pipes/pipes';
46-
export {uninitialized} from './src/change_detection/change_detection_util';
47-
export {WrappedValue, Pipe, PipeFactory, BasePipe} from './src/change_detection/pipes/pipe';
48-
export {NullPipe, NullPipeFactory} from './src/change_detection/pipes/null_pipe';
49-
export {
50-
defaultPipes,
13+
DEFAULT,
14+
15+
ExpressionChangedAfterItHasBeenCheckedException,
16+
ChangeDetectionError,
17+
18+
ChangeDetectorRef,
19+
20+
WrappedValue,
21+
Pipe,
22+
Pipes,
23+
PipeFactory,
24+
BasePipe,
25+
NullPipe,
26+
NullPipeFactory,
27+
28+
ChangeDetector,
29+
ChangeDispatcher,
30+
ChangeDetection,
31+
ChangeDetectorDefinition,
5132
DynamicChangeDetection,
5233
JitChangeDetection,
5334
PreGeneratedChangeDetection,
5435
preGeneratedProtoDetectors
55-
} from './src/change_detection/change_detection';
36+
} from 'angular2/src/change_detection/change_detection';

modules/angular2/core.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ export {Compiler} from 'angular2/src/core/compiler/compiler';
1717
export {AppViewManager} from 'angular2/src/core/compiler/view_manager';
1818
export {IQueryList} from 'angular2/src/core/compiler/interface_query';
1919
export {QueryList} from 'angular2/src/core/compiler/query_list';
20+
export {DynamicComponentLoader} from 'angular2/src/core/compiler/dynamic_component_loader';
21+
2022
export {ElementRef} from 'angular2/src/core/compiler/element_ref';
2123
export {TemplateRef} from 'angular2/src/core/compiler/template_ref';
2224
export {RenderElementRef} from 'angular2/src/render/api';
23-
export {ViewRef, ProtoViewRef} from 'angular2/src/core/compiler/view_ref';
25+
export {ViewRef, HostViewRef, ProtoViewRef} from 'angular2/src/core/compiler/view_ref';
2426
export {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
25-
26-
export {
27-
DynamicComponentLoader,
28-
ComponentRef
29-
} from 'angular2/src/core/compiler/dynamic_component_loader';
27+
export {ComponentRef} from 'angular2/src/core/compiler/dynamic_component_loader';
3028

3129
export {NgZone} from 'angular2/src/core/zone/ng_zone';
3230
export {Observable, EventEmitter} from 'angular2/src/facade/async';

modules/angular2/src/change_detection/change_detection.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,43 @@ import {Inject, Injectable, OpaqueToken, Optional} from 'angular2/di';
1919
import {List, StringMap, StringMapWrapper} from 'angular2/src/facade/collection';
2020
import {CONST, CONST_EXPR, isPresent, BaseException} from 'angular2/src/facade/lang';
2121

22+
export {
23+
ASTWithSource,
24+
AST,
25+
AstTransformer,
26+
AccessMember,
27+
LiteralArray,
28+
ImplicitReceiver
29+
} from './parser/ast';
30+
31+
export {Lexer} from './parser/lexer';
32+
export {Parser} from './parser/parser';
33+
export {Locals} from './parser/locals';
34+
35+
export {
36+
DehydratedException,
37+
ExpressionChangedAfterItHasBeenCheckedException,
38+
ChangeDetectionError
39+
} from './exceptions';
40+
export {
41+
ProtoChangeDetector,
42+
ChangeDetector,
43+
ChangeDispatcher,
44+
ChangeDetection,
45+
ChangeDetectorDefinition
46+
} from './interfaces';
47+
export {CHECK_ONCE, CHECK_ALWAYS, DETACHED, CHECKED, ON_PUSH, DEFAULT} from './constants';
48+
export {DynamicProtoChangeDetector} from './proto_change_detector';
49+
export {BindingRecord} from './binding_record';
50+
export {DirectiveIndex, DirectiveRecord} from './directive_record';
51+
export {DynamicChangeDetector} from './dynamic_change_detector';
52+
export {ChangeDetectorRef} from './change_detector_ref';
53+
export {Pipes} from './pipes/pipes';
54+
export {uninitialized} from './change_detection_util';
55+
export {WrappedValue, Pipe, PipeFactory, BasePipe} from './pipes/pipe';
56+
export {NullPipe, NullPipeFactory} from './pipes/null_pipe';
57+
58+
2259
/**
2360
* Structural diffing for `Object`s and `Map`s.
2461
*/

modules/angular2/src/change_detection/change_detection_util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {isPresent, isBlank, BaseException, Type} from 'angular2/src/facade/lang';
22
import {List, ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
33
import {ProtoRecord} from './proto_record';
4-
import {DehydratedException, ExpressionChangedAfterItHasBeenChecked} from './exceptions';
4+
import {DehydratedException, ExpressionChangedAfterItHasBeenCheckedException} from './exceptions';
55
import {WrappedValue} from './pipes/pipe';
66
import {CHECK_ALWAYS, CHECK_ONCE, CHECKED, DETACHED, ON_PUSH} from './constants';
77

@@ -129,7 +129,7 @@ export class ChangeDetectionUtil {
129129
}
130130

131131
static throwOnChange(proto: ProtoRecord, change) {
132-
throw new ExpressionChangedAfterItHasBeenChecked(proto, change, null);
132+
throw new ExpressionChangedAfterItHasBeenCheckedException(proto, change, null);
133133
}
134134

135135
static throwDehydrated() { throw new DehydratedException(); }

modules/angular2/src/change_detection/change_detector_ref.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import {CHECK_ONCE, DETACHED, CHECK_ALWAYS} from './constants';
55
* Controls change detection.
66
*
77
* {@link ChangeDetectorRef} allows requesting checks for detectors that rely on observables. It
8-
*also allows detaching and
9-
* attaching change detector subtrees.
8+
* also allows detaching and attaching change detector subtrees.
109
*/
1110
export class ChangeDetectorRef {
11+
/**
12+
* @private
13+
*/
1214
constructor(private _cd: ChangeDetector) {}
1315

1416
/**

modules/angular2/src/change_detection/exceptions.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,31 @@
11
import {ProtoRecord} from './proto_record';
22
import {BaseException} from "angular2/src/facade/lang";
33

4-
export class ExpressionChangedAfterItHasBeenChecked extends BaseException {
4+
/**
5+
* An error thrown if application changes model breaking the top-down data flow.
6+
*
7+
* Angular expects that the data flows from top (root) component to child (leaf) components.
8+
* This is known as directed acyclic graph. This allows Angular to only execute change detection
9+
* once and prevents loops in change detection data flow.
10+
*
11+
* This exception is only thrown in dev mode.
12+
*/
13+
export class ExpressionChangedAfterItHasBeenCheckedException extends BaseException {
514
constructor(proto: ProtoRecord, change: any, context: any) {
615
super(`Expression '${proto.expressionAsString}' has changed after it was checked. ` +
716
`Previous value: '${change.previousValue}'. Current value: '${change.currentValue}'`);
817
}
918
}
1019

20+
/**
21+
* Thrown when an expression evaluation raises an exception.
22+
*
23+
* This error wraps the original exception, this is done to attach expression location information.
24+
*/
1125
export class ChangeDetectionError extends BaseException {
26+
/**
27+
* Location of the expression.
28+
*/
1229
location: string;
1330

1431
constructor(proto: ProtoRecord, originalException: any, originalStack: any, context: any) {
@@ -18,6 +35,11 @@ export class ChangeDetectionError extends BaseException {
1835
}
1936
}
2037

38+
/**
39+
* Thrown when change detector executes on dehydrated view.
40+
*
41+
* This is angular internal error.
42+
*/
2143
export class DehydratedException extends BaseException {
2244
constructor() { super('Attempt to detect changes on a dehydrated detector.'); }
2345
}

modules/angular2/src/change_detection/pipes/pipe.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {ChangeDetectorRef} from '../change_detector_ref';
33

44
/**
55
* Indicates that the result of a {@link Pipe} transformation has changed even though the reference
6-
*has not changed.
6+
* has not changed.
77
*
88
* The wrapped value will be unwrapped by change detection, and the unwrapped value will be stored.
99
*/
@@ -28,9 +28,7 @@ var _wrappedValues = [
2828
var _wrappedIndex = 0;
2929

3030
/**
31-
* An interface for extending the list of pipes known to Angular.
32-
*
33-
* If you are writing a custom {@link Pipe}, you must extend this interface.
31+
* An interface which all pipes must implement.
3432
*
3533
* #Example
3634
*
@@ -49,18 +47,23 @@ var _wrappedIndex = 0;
4947
* ```
5048
*/
5149
export interface Pipe {
50+
/**
51+
* Query if a pipe supports a particular object instance.
52+
*/
5253
supports(obj): boolean;
54+
5355
onDestroy(): void;
56+
5457
transform(value: any, args: List<any>): any;
5558
}
5659

5760
/**
58-
* Provides default implementation of supports and onDestroy.
61+
* Provides default implementation of `supports` and `onDestroy` method.
5962
*
6063
* #Example
6164
*
6265
* ```
63-
* class DoublePipe extends BasePipe {*
66+
* class DoublePipe extends BasePipe {
6467
* transform(value) {
6568
* return `${value}${value}`;
6669
* }
@@ -74,6 +77,9 @@ export class BasePipe implements Pipe {
7477
transform(value: any, args: List<any>): any { return _abstract(); }
7578
}
7679

80+
/**
81+
*
82+
*/
7783
export interface PipeFactory {
7884
supports(obs): boolean;
7985
create(cdRef: ChangeDetectorRef): Pipe;

modules/angular2/src/change_detection/pipes/pipes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export class Pipes {
2626
* ```
2727
*/
2828
config: StringMap<string, PipeFactory[]>;
29+
30+
2931
constructor(config: StringMap<string, PipeFactory[]>) { this.config = config; }
3032

3133
get(type: string, obj: any, cdRef?: ChangeDetectorRef, existingPipe?: Pipe): Pipe {

0 commit comments

Comments
 (0)