From f197ce240eaa7c694271b8151baf2e11c7216e6f Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Thu, 11 May 2017 16:58:50 -0700 Subject: [PATCH] Accept boolean or object map for dynamicFns --- lib/mixins/property-effects.html | 43 ++++++++++++++++---------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/mixins/property-effects.html b/lib/mixins/property-effects.html index 1cf772869a..7c8c16ceba 100644 --- a/lib/mixins/property-effects.html +++ b/lib/mixins/property-effects.html @@ -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, @@ -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); } /** @@ -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 ------------ @@ -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); } /** @@ -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); } /**