@@ -200,8 +200,6 @@ class Scope {
200
200
* evaluates to a non-null value.
201
201
* * [reactionFn] : The reaction function to execute when a change is detected in the watched
202
202
* expression.
203
- * * [context] : The object against which the expression is evaluated. This defaults to the
204
- * [Scope.context] if no context is specified.
205
203
* * [formatters] : If the watched expression contains formatters,
206
204
* this map specifies the set of formatters that are used by the expression.
207
205
* * [canChangeModel] : Specifies whether the [reactionFn] changes the model. Reaction
@@ -218,6 +216,27 @@ class Scope {
218
216
assert (expression is String );
219
217
assert (canChangeModel is bool );
220
218
219
+ // TODO(deboer): Temporary shim until all uses are fixed.
220
+ if (context != null ) {
221
+ assert (() {
222
+ try {
223
+ throw [];
224
+ } catch (e, s) {
225
+ var msg = "WARNING: The Scope.watch's context parameter "
226
+ "is deprecated.\n Scope.watch was called from:\n $s " ;
227
+ _oneTimeWarnings.putIfAbsent (msg, () => print (msg));
228
+ }
229
+ return true ;
230
+ });
231
+
232
+ // Create a child scope instead.
233
+ return createChild (context)
234
+ .watch (expression, reactionFn,
235
+ formatters: formatters,
236
+ canChangeModel: canChangeModel,
237
+ collection: collection);
238
+ }
239
+
221
240
Watch watch;
222
241
ReactionFn fn = reactionFn;
223
242
if (expression.isEmpty) {
@@ -239,12 +258,13 @@ class Scope {
239
258
}
240
259
}
241
260
242
- AST ast = rootScope._astParser (expression, context : context,
261
+ AST ast = rootScope._astParser (expression,
243
262
formatters: formatters, collection: collection);
244
263
245
264
WatchGroup group = canChangeModel ? _readWriteGroup : _readOnlyGroup;
246
265
return watch = group.watch (ast, fn);
247
266
}
267
+ static Map _oneTimeWarnings = {};
248
268
249
269
dynamic eval (expression, [Map locals]) {
250
270
assert (isAttached);
@@ -1052,14 +1072,10 @@ class _AstParser {
1052
1072
: _visitor = new ExpressionVisitor (closureMap);
1053
1073
1054
1074
AST call (String input, {FormatterMap formatters,
1055
- bool collection: false ,
1056
- Object context: null }) {
1075
+ bool collection: false }) {
1057
1076
_visitor.formatters = formatters;
1058
1077
AST contextRef = _visitor.contextRef;
1059
1078
try {
1060
- if (context != null ) {
1061
- _visitor.contextRef = new ConstantAST (context, '#${_id ++}' );
1062
- }
1063
1079
var exp = _parser (input);
1064
1080
return collection ? _visitor.visitCollection (exp) : _visitor.visit (exp);
1065
1081
} finally {
0 commit comments