From 5f35b2bda57136a1c13d52a326cd1e85a966bd4e Mon Sep 17 00:00:00 2001 From: Samuel Reed Date: Sun, 17 Aug 2014 19:45:09 -0400 Subject: [PATCH] Allow marking mixin functions as unchainable. --- lib/create_store.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/create_store.js b/lib/create_store.js index cdf8088..cb78f5d 100644 --- a/lib/create_store.js +++ b/lib/create_store.js @@ -48,7 +48,8 @@ createStore.mixSpecIntoComponent = function mixSpecIntoComponent(component, spec // Functions are chained, with mixin functions being run before spec functions. else if (typeof spec[key] === "function") { - if (component[key]) { + // Allow users to mark a function as unchainable via 'chainable' + if (component[key] && component[key].chainable !== false) { // Only functions can be chained. if (typeof component[key] !== "function") { throw new FunctionChainingError(key); @@ -56,6 +57,7 @@ createStore.mixSpecIntoComponent = function mixSpecIntoComponent(component, spec component[key] = createStore.createChainedFunction(component[key], spec[key]).bind(component); } else { component[key] = spec[key].bind(component); + if (spec[key].chainable === false) component[key].chainable = false; } }