Skip to content

Commit a2376b6

Browse files
author
Steven Orvell
committed
provides support for memoizing pathFn on effect;
only process effects/listeners if they exist.
1 parent d93340a commit a2376b6

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎src/lib/bind/accessors.html‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
_dataEventCache: {},
1515

1616
// for prototypes (usually)
17-
1817
prepareModel: function(model) {
19-
model._propertyEffects = {};
20-
model._bindListeners = [];
2118
Polymer.Base.mixin(model, this._modelApi);
2219
},
2320

@@ -106,6 +103,9 @@
106103
// a prepared model can acquire effects
107104

108105
ensurePropertyEffects: function(model, property) {
106+
if (!model._propertyEffects) {
107+
model._propertyEffects = {};
108+
}
109109
var fx = model._propertyEffects[property];
110110
if (!fx) {
111111
fx = model._propertyEffects[property] = [];
@@ -115,11 +115,13 @@
115115

116116
addPropertyEffect: function(model, property, kind, effect) {
117117
var fx = this.ensurePropertyEffects(model, property);
118-
fx.push({
118+
var propEffect = {
119119
kind: kind,
120120
effect: effect,
121121
fn: Polymer.Bind['_' + kind + 'Effect']
122-
});
122+
};
123+
fx.push(propEffect);
124+
return propEffect;
123125
},
124126

125127
createBindings: function(model) {
@@ -193,6 +195,9 @@
193195
},
194196

195197
_addAnnotatedListener: function(model, index, property, path, event) {
198+
if (!model._bindListeners) {
199+
model._bindListeners = [];
200+
}
196201
var fn = this._notedListenerFactory(property, path,
197202
this._isStructured(path));
198203
var eventName = event ||

0 commit comments

Comments
 (0)