Skip to content

Commit

Permalink
feat(scope): Expose Scope.watchAST as a public API
Browse files Browse the repository at this point in the history
  • Loading branch information
jbdeboer committed May 30, 2014
1 parent c68933d commit 320fc02
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/core/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,19 @@ class Scope {
AST ast = rootScope._astParser(expression,
formatters: formatters, collection: collection);

return watch = watchAST(ast, fn, canChangeModel: canChangeModel);
}

/**
* Use [watch] to set up change detection on an pre-parsed AST.
*
* * [ast] The pre-parsed AST.
* * [reactionFn]: The function executed when a change is detected.
* * [canChangeModel]: Whether or not the [reactionFn] can change the model.
*/
Watch watchAST(AST ast, ReactionFn reactionFn, {bool canChangeModel: true}) {
WatchGroup group = canChangeModel ? _readWriteGroup : _readOnlyGroup;
return watch = group.watch(ast, fn);
return group.watch(ast, reactionFn);
}

dynamic eval(expression, [Map locals]) {
Expand Down

0 comments on commit 320fc02

Please sign in to comment.