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

Commit b6ee1d6

Browse files
vicbchirayuk
authored andcommitted
doc(annotations): improve the doc for @NgCallback
Closes #1296 Closes #1298
1 parent 449cedf commit b6ee1d6

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

lib/core/annotation_src.dart

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,12 @@ abstract class Directive {
152152
* watch on expression. Once the expression turns truthy it will no longer
153153
* update. (cost: 1 watches until not null, then 0 watches)
154154
*
155-
* * `&` - Treat the DOM attribute value as an expression. Assign a closure
156-
* function into the field. This allows the component to control
157-
* the invocation of the closure. This is useful for passing
158-
* expressions into controllers which act like callbacks. (cost: 0 watches)
155+
* * `&` - Treat the DOM attribute value as an expression. The expression is
156+
* compiled and bound to the scope context. The resulting [BoundExpression]
157+
* is assigned to the designated field. The component can evaluate the
158+
* expression by calling the [BoundExpression] when needed. This is useful
159+
* for passing expressions into controllers which act like callbacks. (cost:
160+
* 0 watches)
159161
*
160162
* Example:
161163
*
@@ -172,25 +174,25 @@ abstract class Directive {
172174
* class MyComponent {
173175
* String title;
174176
* var currentItem;
175-
* ParsedFn onChange;
177+
* BoundExpression onChange;
176178
* }
177179
*
178-
* The above example shows how all three mapping modes are used.
180+
* The above example shows how all three mapping modes are used:
179181
*
180-
* * `@title` maps the title DOM attribute to the controller `title`
182+
* * `@title` maps the title DOM attribute to the component `title`
181183
* field. Notice that this maps the content of the attribute, which
182184
* means that it can be used with `{{}}` interpolation.
183185
*
184186
* * `<=>currentItem` maps the expression (in this case the `selectedItem`
185-
* in the current scope into the `currentItem` in the controller. Notice
187+
* in the current scope into the `currentItem` in the component. Notice
186188
* that mapping is bi-directional. A change either in field or on
187189
* parent scope will result in change to the other.
188190
*
189-
* * `&onChange` maps the expression into the controller `onChange`
190-
* field. The result of mapping is a callable function which can be
191-
* invoked at any time by the controller. The invocation of the
192-
* callable function will result in the expression `doSomething()` to
193-
* be executed in the parent context.
191+
* * `&onChange` parse the expression (`doSomething()`), bind it to the
192+
* parent context, the resulting [BoundExpression] is assigned to the
193+
* controller `onChange` field. The [BoundExpression] is a callable object
194+
* which can be invoked at any time by the component. The invocation of
195+
* `onChange` will result in the expression `doSomething()` to be executed.
194196
*/
195197
final Map<String, String> map;
196198

@@ -512,10 +514,9 @@ class NgTwoWay extends DirectiveAnnotation {
512514
}
513515

514516
/**
515-
* When applied as an annotation on a directive field specifies that
516-
* the field is to be mapped to DOM attribute with the provided [attrName].
517-
* The value of the attribute to be treated as a callback expression,
518-
* equivalent to `&` specification.
517+
* When applied as an annotation on a directive field specifies that the field is to be mapped to
518+
* DOM attribute with the provided [attrName]. The value of the attribute to be treated as a
519+
* an expression, equivalent to `&` specification.
519520
*/
520521
class NgCallback extends DirectiveAnnotation {
521522
final _mappingSpec = '&';

0 commit comments

Comments
 (0)