@@ -14,6 +14,10 @@ typedef EvalFunction1(context);
14
14
class ScopeEvent {
15
15
static final String DESTROY = 'ng-destroy' ;
16
16
17
+ /**
18
+ * Data attached to the event. This would be the optional parameter
19
+ * from [Scope.emit] and [Scope.broadcast] .
20
+ */
17
21
final data;
18
22
19
23
/**
@@ -27,7 +31,10 @@ class ScopeEvent {
27
31
final Scope targetScope;
28
32
29
33
/**
30
- * The destination scope that intercepted the event.
34
+ * The destination scope that intercepted the event. As
35
+ * the event traverses the scope hierarchy the the event instance
36
+ * stays the same, but the [currentScope] reflects the scope
37
+ * of the current listener which is firing.
31
38
*/
32
39
Scope get currentScope => _currentScope;
33
40
Scope _currentScope;
@@ -118,12 +125,35 @@ class ScopeLocals implements Map {
118
125
dynamic putIfAbsent (key, fn) => _scope.putIfAbsent (key, fn);
119
126
}
120
127
128
+ /**
129
+ * [Scope] is represents a collection of [watch] es [observe] ers, and [context]
130
+ * for the watchers, observers and [eval] uations. Scopes structure loosely
131
+ * mimics the DOM structure. Scopes and [Block] s are bound to each other.
132
+ * As scopes are created and destroyed by [BlockFactory] they are responsible
133
+ * for change detection, change processing and memory management.
134
+ */
121
135
class Scope {
136
+
137
+ /**
138
+ * The default execution context for [watch] es [observe] ers, and [eval] uation.
139
+ */
122
140
final context;
141
+
142
+ /**
143
+ * The [RootScope] of the application.
144
+ */
123
145
final RootScope rootScope;
146
+
124
147
Scope _parentScope;
148
+
149
+ /**
150
+ * The parent [Scope] .
151
+ */
125
152
Scope get parentScope => _parentScope;
126
153
154
+ // TODO(misko): WatchGroup should be private.
155
+ // Instead we should expose performance stats about the watches
156
+ // such as # of watches, checks/1ms, field checks, function checks, etc
127
157
final WatchGroup watchGroup;
128
158
final WatchGroup observeGroup;
129
159
final int _depth;
@@ -136,6 +166,12 @@ class Scope {
136
166
Scope (Object this .context, this .rootScope, this ._parentScope, this ._depth,
137
167
this ._index, this .watchGroup, this .observeGroup);
138
168
169
+ /**
170
+ * A [watch] sets up a watch in the [digest] phase of the [apply] cycle.
171
+ *
172
+ * Use [watch] if the reaction function can cause updates to model. In your
173
+ * controller code you will most likely use [watch] .
174
+ */
139
175
Watch watch (expression, ReactionFn reactionFn, {context, FilterMap filters}) {
140
176
assert (expression != null );
141
177
AST ast = expression is AST
0 commit comments