Skip to content

Commit 922e20f

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

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
@@ -261,8 +261,19 @@ class Scope {
261261
AST ast = rootScope._astParser(expression,
262262
formatters: formatters, collection: collection);
263263

264+
return watch = watchAST(ast, fn, canChangeModel: canChangeModel);
265+
}
266+
267+
/**
268+
* Use [watch] to set up change detection on an pre-parsed AST.
269+
*
270+
* * [ast] The pre-parsed AST.
271+
* * [reactionFn]: The function executed when a change is detected.
272+
* * [canChangeModel]: Whether or not the [reactionFn] can change the model.
273+
*/
274+
Watch watchAST(AST ast, ReactionFn reactionFn, {bool canChangeModel: true}) {
264275
WatchGroup group = canChangeModel ? _readWriteGroup : _readOnlyGroup;
265-
return watch = group.watch(ast, fn);
276+
return group.watch(ast, reactionFn);
266277
}
267278
static Map _oneTimeWarnings = {};
268279

0 commit comments

Comments
 (0)