Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

doc(annotations): Improve the DartDoc for @NgCallback #1298

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions lib/core/annotation_src.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,11 @@ abstract class Directive {
* watch on expression. Once the expression turns truthy it will no longer
* update. (cost: 1 watches until not null, then 0 watches)
*
* * `&` - Treat the DOM attribute value as an expression. Assign a closure
* function into the field. This allows the component to control
* the invocation of the closure. This is useful for passing
* expressions into controllers which act like callbacks. (cost: 0 watches)
* * `&` - Treat the DOM attribute value as an expression. The expression is compiled and bound
* to the scope context. The resulting [BoundExpression] is assigned to the designated field.
* The component can evaluate the expression by calling the [BoundExpression] when needed.
* This is useful for passing expressions into controllers which act like callbacks. (cost:
* 0 watches)
*
* Example:
*
Expand All @@ -172,25 +173,25 @@ abstract class Directive {
* class MyComponent {
* String title;
* var currentItem;
* ParsedFn onChange;
* BoundExpression onChange;
* }
*
* The above example shows how all three mapping modes are used.
* The above example shows how all three mapping modes are used:
*
* * `@title` maps the title DOM attribute to the controller `title`
* * `@title` maps the title DOM attribute to the component `title`
* field. Notice that this maps the content of the attribute, which
* means that it can be used with `{{}}` interpolation.
*
* * `<=>currentItem` maps the expression (in this case the `selectedItem`
* in the current scope into the `currentItem` in the controller. Notice
* in the current scope into the `currentItem` in the component. Notice
* that mapping is bi-directional. A change either in field or on
* parent scope will result in change to the other.
*
* * `&onChange` maps the expression into the controller `onChange`
* field. The result of mapping is a callable function which can be
* invoked at any time by the controller. The invocation of the
* callable function will result in the expression `doSomething()` to
* be executed in the parent context.
* * `&onChange` parse the expression (`doSomething()`), bind it to the parent context, the
* resulting [BoundExpression] is assigned to the controller `onChange` field. The
* [BoundExpression] is a callable object which can be invoked at any time by the component.
* The invocation of `onChange` will result in the expression `doSomething()` to be
* executed.
*/
final Map<String, String> map;

Expand Down Expand Up @@ -512,10 +513,9 @@ class NgTwoWay extends DirectiveAnnotation {
}

/**
* When applied as an annotation on a directive field specifies that
* the field is to be mapped to DOM attribute with the provided [attrName].
* The value of the attribute to be treated as a callback expression,
* equivalent to `&` specification.
* When applied as an annotation on a directive field specifies that the field is to be mapped to
* DOM attribute with the provided [attrName]. The value of the attribute to be treated as a
* an expression, equivalent to `&` specification.
*/
class NgCallback extends DirectiveAnnotation {
final _mappingSpec = '&';
Expand Down