chore(docs): added more docs for core.ts
This commit is contained in:
@ -19,6 +19,43 @@ import {Inject, Injectable, OpaqueToken, Optional} from 'angular2/di';
|
||||
import {List, StringMap, StringMapWrapper} from 'angular2/src/facade/collection';
|
||||
import {CONST, CONST_EXPR, isPresent, BaseException} from 'angular2/src/facade/lang';
|
||||
|
||||
export {
|
||||
ASTWithSource,
|
||||
AST,
|
||||
AstTransformer,
|
||||
AccessMember,
|
||||
LiteralArray,
|
||||
ImplicitReceiver
|
||||
} from './parser/ast';
|
||||
|
||||
export {Lexer} from './parser/lexer';
|
||||
export {Parser} from './parser/parser';
|
||||
export {Locals} from './parser/locals';
|
||||
|
||||
export {
|
||||
DehydratedException,
|
||||
ExpressionChangedAfterItHasBeenCheckedException,
|
||||
ChangeDetectionError
|
||||
} from './exceptions';
|
||||
export {
|
||||
ProtoChangeDetector,
|
||||
ChangeDetector,
|
||||
ChangeDispatcher,
|
||||
ChangeDetection,
|
||||
ChangeDetectorDefinition
|
||||
} from './interfaces';
|
||||
export {CHECK_ONCE, CHECK_ALWAYS, DETACHED, CHECKED, ON_PUSH, DEFAULT} from './constants';
|
||||
export {DynamicProtoChangeDetector} from './proto_change_detector';
|
||||
export {BindingRecord} from './binding_record';
|
||||
export {DirectiveIndex, DirectiveRecord} from './directive_record';
|
||||
export {DynamicChangeDetector} from './dynamic_change_detector';
|
||||
export {ChangeDetectorRef} from './change_detector_ref';
|
||||
export {Pipes} from './pipes/pipes';
|
||||
export {uninitialized} from './change_detection_util';
|
||||
export {WrappedValue, Pipe, PipeFactory, BasePipe} from './pipes/pipe';
|
||||
export {NullPipe, NullPipeFactory} from './pipes/null_pipe';
|
||||
|
||||
|
||||
/**
|
||||
* Structural diffing for `Object`s and `Map`s.
|
||||
*/
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {isPresent, isBlank, BaseException, Type} from 'angular2/src/facade/lang';
|
||||
import {List, ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
|
||||
import {ProtoRecord} from './proto_record';
|
||||
import {DehydratedException, ExpressionChangedAfterItHasBeenChecked} from './exceptions';
|
||||
import {DehydratedException, ExpressionChangedAfterItHasBeenCheckedException} from './exceptions';
|
||||
import {WrappedValue} from './pipes/pipe';
|
||||
import {CHECK_ALWAYS, CHECK_ONCE, CHECKED, DETACHED, ON_PUSH} from './constants';
|
||||
|
||||
@ -129,7 +129,7 @@ export class ChangeDetectionUtil {
|
||||
}
|
||||
|
||||
static throwOnChange(proto: ProtoRecord, change) {
|
||||
throw new ExpressionChangedAfterItHasBeenChecked(proto, change, null);
|
||||
throw new ExpressionChangedAfterItHasBeenCheckedException(proto, change, null);
|
||||
}
|
||||
|
||||
static throwDehydrated() { throw new DehydratedException(); }
|
||||
|
@ -5,10 +5,12 @@ import {CHECK_ONCE, DETACHED, CHECK_ALWAYS} from './constants';
|
||||
* Controls change detection.
|
||||
*
|
||||
* {@link ChangeDetectorRef} allows requesting checks for detectors that rely on observables. It
|
||||
*also allows detaching and
|
||||
* attaching change detector subtrees.
|
||||
* also allows detaching and attaching change detector subtrees.
|
||||
*/
|
||||
export class ChangeDetectorRef {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
constructor(private _cd: ChangeDetector) {}
|
||||
|
||||
/**
|
||||
|
@ -1,14 +1,31 @@
|
||||
import {ProtoRecord} from './proto_record';
|
||||
import {BaseException} from "angular2/src/facade/lang";
|
||||
|
||||
export class ExpressionChangedAfterItHasBeenChecked extends BaseException {
|
||||
/**
|
||||
* An error thrown if application changes model breaking the top-down data flow.
|
||||
*
|
||||
* Angular expects that the data flows from top (root) component to child (leaf) components.
|
||||
* This is known as directed acyclic graph. This allows Angular to only execute change detection
|
||||
* once and prevents loops in change detection data flow.
|
||||
*
|
||||
* This exception is only thrown in dev mode.
|
||||
*/
|
||||
export class ExpressionChangedAfterItHasBeenCheckedException extends BaseException {
|
||||
constructor(proto: ProtoRecord, change: any, context: any) {
|
||||
super(`Expression '${proto.expressionAsString}' has changed after it was checked. ` +
|
||||
`Previous value: '${change.previousValue}'. Current value: '${change.currentValue}'`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown when an expression evaluation raises an exception.
|
||||
*
|
||||
* This error wraps the original exception, this is done to attach expression location information.
|
||||
*/
|
||||
export class ChangeDetectionError extends BaseException {
|
||||
/**
|
||||
* Location of the expression.
|
||||
*/
|
||||
location: string;
|
||||
|
||||
constructor(proto: ProtoRecord, originalException: any, originalStack: any, context: any) {
|
||||
@ -18,6 +35,11 @@ export class ChangeDetectionError extends BaseException {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown when change detector executes on dehydrated view.
|
||||
*
|
||||
* This is angular internal error.
|
||||
*/
|
||||
export class DehydratedException extends BaseException {
|
||||
constructor() { super('Attempt to detect changes on a dehydrated detector.'); }
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import {ChangeDetectorRef} from '../change_detector_ref';
|
||||
|
||||
/**
|
||||
* Indicates that the result of a {@link Pipe} transformation has changed even though the reference
|
||||
*has not changed.
|
||||
* has not changed.
|
||||
*
|
||||
* The wrapped value will be unwrapped by change detection, and the unwrapped value will be stored.
|
||||
*/
|
||||
@ -28,9 +28,7 @@ var _wrappedValues = [
|
||||
var _wrappedIndex = 0;
|
||||
|
||||
/**
|
||||
* An interface for extending the list of pipes known to Angular.
|
||||
*
|
||||
* If you are writing a custom {@link Pipe}, you must extend this interface.
|
||||
* An interface which all pipes must implement.
|
||||
*
|
||||
* #Example
|
||||
*
|
||||
@ -49,18 +47,23 @@ var _wrappedIndex = 0;
|
||||
* ```
|
||||
*/
|
||||
export interface Pipe {
|
||||
/**
|
||||
* Query if a pipe supports a particular object instance.
|
||||
*/
|
||||
supports(obj): boolean;
|
||||
|
||||
onDestroy(): void;
|
||||
|
||||
transform(value: any, args: List<any>): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides default implementation of supports and onDestroy.
|
||||
* Provides default implementation of `supports` and `onDestroy` method.
|
||||
*
|
||||
* #Example
|
||||
*
|
||||
* ```
|
||||
* class DoublePipe extends BasePipe {*
|
||||
* class DoublePipe extends BasePipe {
|
||||
* transform(value) {
|
||||
* return `${value}${value}`;
|
||||
* }
|
||||
@ -74,6 +77,9 @@ export class BasePipe implements Pipe {
|
||||
transform(value: any, args: List<any>): any { return _abstract(); }
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export interface PipeFactory {
|
||||
supports(obs): boolean;
|
||||
create(cdRef: ChangeDetectorRef): Pipe;
|
||||
|
@ -26,6 +26,8 @@ export class Pipes {
|
||||
* ```
|
||||
*/
|
||||
config: StringMap<string, PipeFactory[]>;
|
||||
|
||||
|
||||
constructor(config: StringMap<string, PipeFactory[]>) { this.config = config; }
|
||||
|
||||
get(type: string, obj: any, cdRef?: ChangeDetectorRef, existingPipe?: Pipe): Pipe {
|
||||
|
Reference in New Issue
Block a user