provides support for memoizing pathFn on effect;

only process effects/listeners if they exist.
This commit is contained in:
Steven Orvell 2015-11-02 17:24:44 -08:00
parent d93340a209
commit a2376b6e95

View File

@ -14,10 +14,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_dataEventCache: {},
// for prototypes (usually)
prepareModel: function(model) {
model._propertyEffects = {};
model._bindListeners = [];
Polymer.Base.mixin(model, this._modelApi);
},
@ -106,6 +103,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// a prepared model can acquire effects
ensurePropertyEffects: function(model, property) {
if (!model._propertyEffects) {
model._propertyEffects = {};
}
var fx = model._propertyEffects[property];
if (!fx) {
fx = model._propertyEffects[property] = [];
@ -115,11 +115,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
addPropertyEffect: function(model, property, kind, effect) {
var fx = this.ensurePropertyEffects(model, property);
fx.push({
var propEffect = {
kind: kind,
effect: effect,
fn: Polymer.Bind['_' + kind + 'Effect']
});
};
fx.push(propEffect);
return propEffect;
},
createBindings: function(model) {
@ -193,6 +195,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
},
_addAnnotatedListener: function(model, index, property, path, event) {
if (!model._bindListeners) {
model._bindListeners = [];
}
var fn = this._notedListenerFactory(property, path,
this._isStructured(path));
var eventName = event ||