Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 195f043

Browse files
committed
chore(scope): remove watchSet API
1 parent 266a8eb commit 195f043

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

lib/core/scope.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,6 @@ class Scope {
127127
Scope(Object this.context, this.rootScope, this._parentScope, this._depth,
128128
this._index, this.watchGroup, this.observeGroup);
129129

130-
// TODO(misko): this is a hack and should be removed
131-
// A better way to do this is to remove the parser from the scope.
132-
Watch watchSet(List<String> exprs, Function reactionFn) {
133-
var expr = '{{${exprs.join('}}?{{')}}}';
134-
List items = exprs.map(rootScope._parse).toList();
135-
AST ast = new PureFunctionAST(expr, new ArrayFn(), items);
136-
return watchGroup.watch(ast, reactionFn);
137-
}
138-
139130
Watch watch(expression, ReactionFn reactionFn) {
140131
// Todo(misko): remove the parser from here. It should only take AST.
141132
assert(expression != null);

lib/directive/ng_pluralize.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,14 @@ class NgPluralizeDirective {
9292
final dom.Element element;
9393
final Scope scope;
9494
final Interpolate interpolate;
95+
final AstParser parser;
9596
int offset;
9697
Map<String, String> discreteRules = new Map();
9798
Map<Symbol, String> categoryRules = new Map();
9899
static final RegExp IS_WHEN = new RegExp(r'^when-(minus-)?.');
99100

100101
NgPluralizeDirective(this.scope, this.element, this.interpolate,
101-
NodeAttrs attributes) {
102+
NodeAttrs attributes, this.parser) {
102103
Map<String, String> whens = attributes['when'] == null ?
103104
{} :
104105
scope.eval(attributes['when']);
@@ -156,6 +157,8 @@ class NgPluralizeDirective {
156157
var interpolation = interpolate(expression, false, '\${', '}');
157158
interpolation.setter = (text) => element.text = text;
158159
interpolation.setter(expression);
159-
scope.watchSet(interpolation.expressions, interpolation.call);
160+
List items = interpolation.expressions.map((exp) => parser(exp)).toList();
161+
AST ast = new PureFunctionAST(expression, new ArrayFn(), items);
162+
scope.watch(ast, interpolation.call);
160163
}
161164
}

0 commit comments

Comments
 (0)