Skip to content

Commit

Permalink
provides support for memoizing pathFn on effect;
Browse files Browse the repository at this point in the history
only process effects/listeners if they exist.
  • Loading branch information
Steven Orvell committed Nov 3, 2015
1 parent d93340a commit a2376b6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/lib/bind/accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
_dataEventCache: {},

// for prototypes (usually)

prepareModel: function(model) {
model._propertyEffects = {};
model._bindListeners = [];
Polymer.Base.mixin(model, this._modelApi);
},

Expand Down Expand Up @@ -106,6 +103,9 @@
// 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] = [];
Expand All @@ -115,11 +115,13 @@

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) {
Expand Down Expand Up @@ -193,6 +195,9 @@
},

_addAnnotatedListener: function(model, index, property, path, event) {
if (!model._bindListeners) {
model._bindListeners = [];
}
var fn = this._notedListenerFactory(property, path,
this._isStructured(path));
var eventName = event ||
Expand Down

0 comments on commit a2376b6

Please sign in to comment.