Skip to content

Commit f6885af

Browse files
committed
feat(scope): Expose Scope.watchAST as a public API
For dart-archive#1086
1 parent c04860f commit f6885af

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/core/scope.dart

+12-1
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,19 @@ class Scope {
240240
AST ast = rootScope._astParser(expression,
241241
formatters: formatters, collection: collection);
242242

243+
return watch = watchAST(ast, fn, canChangeModel: canChangeModel);
244+
}
245+
246+
/**
247+
* Use [watch] to set up change detection on an pre-parsed AST.
248+
*
249+
* * [ast] The pre-parsed AST.
250+
* * [reactionFn]: The function executed when a change is detected.
251+
* * [canChangeModel]: Whether or not the [reactionFn] can change the model.
252+
*/
253+
Watch watchAST(AST ast, ReactionFn reactionFn, {bool canChangeModel: true}) {
243254
WatchGroup group = canChangeModel ? _readWriteGroup : _readOnlyGroup;
244-
return watch = group.watch(ast, fn);
255+
return group.watch(ast, reactionFn);
245256
}
246257

247258
dynamic eval(expression, [Map locals]) {

0 commit comments

Comments
 (0)