Skip to content

Commit

Permalink
Accept boolean or object map for dynamicFns
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed May 11, 2017
1 parent 4223043 commit f197ce2
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions lib/mixins/property-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,14 @@
* @param {Function} effectFn Function to run when arguments change
* @param {*=} methodInfo Effect-specific information to be included in
* method effect metadata
* @param {Object=} dynamicFns Map indicating whether method names should
* be included as a dependency to the effect. Note, defaults to true
* if the signature is statci (sig.static is true).
* @param {boolean|Object=} dynamicFn Boolean or object map indicating whether
* method names should be included as a dependency to the effect. Note,
* defaults to true if the signature is static (sig.static is true).
* @private
*/
function createMethodEffect(model, sig, type, effectFn, methodInfo, dynamicFns) {
let dynamicFn = sig.static || dynamicFns && dynamicFns[sig.methodName];
function createMethodEffect(model, sig, type, effectFn, methodInfo, dynamicFn) {
dynamicFn = sig.static || (dynamicFn &&
(typeof dynamicFn !== 'object' || dynamicFn[sig.methodName]));
let info = {
methodName: sig.methodName,
args: sig.args,
Expand Down Expand Up @@ -1897,16 +1898,16 @@
* full API docs.
*
* @param {string} expression Method expression
* @param {Object=} dynamicFns Map indicating whether method names should
* be included as a dependency to the effect.
* @param {boolean|Object=} dynamicFn Boolean or object map indicating
* whether method names should be included as a dependency to the effect.
* @protected
*/
_createMethodObserver(expression, dynamicFns) {
_createMethodObserver(expression, dynamicFn) {
let sig = parseMethod(expression);
if (!sig) {
throw new Error("Malformed observer expression '" + expression + "'");
}
createMethodEffect(this, sig, TYPES.OBSERVE, runMethodEffect, null, dynamicFns);
createMethodEffect(this, sig, TYPES.OBSERVE, runMethodEffect, null, dynamicFn);
}

/**
Expand Down Expand Up @@ -1957,16 +1958,16 @@
*
* @param {string} property Name of computed property to set
* @param {string} expression Method expression
* @param {Object=} dynamicFns Map indicating whether method names should
* be included as a dependency to the effect.
* @param {boolean|Object=} dynamicFn Boolean or object map indicating
* whether method names should be included as a dependency to the effect.
* @protected
*/
_createComputedProperty(property, expression, dynamicFns) {
_createComputedProperty(property, expression, dynamicFn) {
let sig = parseMethod(expression);
if (!sig) {
throw new Error("Malformed computed expression '" + expression + "'");
}
createMethodEffect(this, sig, TYPES.COMPUTE, runComputedEffect, property, dynamicFns);
createMethodEffect(this, sig, TYPES.COMPUTE, runComputedEffect, property, dynamicFn);
}

// -- static class methods ------------
Expand Down Expand Up @@ -2031,12 +2032,12 @@
* prototype (or instance), or may be a literal string or number.
*
* @param {string} expression Method expression
* @param {Object=} dynamicFns Map indicating whether method names should
* be included as a dependency to the effect.
* @param {boolean|Object=} dynamicFn Boolean or object map indicating
* whether method names should be included as a dependency to the effect.
* @protected
*/
static createMethodObserver(expression, dynamicFns) {
this.prototype._createMethodObserver(expression, dynamicFns);
static createMethodObserver(expression, dynamicFn) {
this.prototype._createMethodObserver(expression, dynamicFn);
}

/**
Expand Down Expand Up @@ -2089,12 +2090,12 @@
*
* @param {string} property Name of computed property to set
* @param {string} expression Method expression
* @param {Object=} dynamicFns Map indicating whether method names should
* be included as a dependency to the effect.
* @param {boolean|Object=} dynamicFn Boolean or object map indicating whether
* method names should be included as a dependency to the effect.
* @protected
*/
static createComputedProperty(property, expression, dynamicFns) {
this.prototype._createComputedProperty(property, expression, dynamicFns);
static createComputedProperty(property, expression, dynamicFn) {
this.prototype._createComputedProperty(property, expression, dynamicFn);
}

/**
Expand Down

0 comments on commit f197ce2

Please sign in to comment.