flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [1/4] git commit: [flex-asjs] [refs/heads/develop] - wrap goog.bind so it generates the same closure every time
Date Fri, 21 Aug 2015 14:19:02 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop fcd85776a -> 4ba97a19f


wrap goog.bind so it generates the same closure every time


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/4dcbde2e
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/4dcbde2e
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/4dcbde2e

Branch: refs/heads/develop
Commit: 4dcbde2e87f41569de645f7b8c99e10cf8dfd2b9
Parents: fcd8577
Author: Alex Harui <aharui@apache.org>
Authored: Thu Aug 20 16:30:48 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Thu Aug 20 16:30:48 2015 -0700

----------------------------------------------------------------------
 .../js/src/org/apache/flex/utils/Language.js    | 21 ++++++++++++++++++++
 1 file changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4dcbde2e/frameworks/projects/Core/js/src/org/apache/flex/utils/Language.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/org/apache/flex/utils/Language.js b/frameworks/projects/Core/js/src/org/apache/flex/utils/Language.js
index f55228e..f95b659 100644
--- a/frameworks/projects/Core/js/src/org/apache/flex/utils/Language.js
+++ b/frameworks/projects/Core/js/src/org/apache/flex/utils/Language.js
@@ -293,3 +293,24 @@ org.apache.flex.utils.Language.superSetter = function(clazz, pthis, prop,
value)
   }
   superdesc.set.apply(pthis, [value]);
 };
+
+
+/**
+ * caches closures and returns the one closure
+ *
+ * @export
+ * @param {Function} fn The method on the instance.
+ * @param {Object} object The instance.
+ * @param {string} boundMethodName The name to use to cache the closure.
+ * @return {Function} The closure.
+ */
+org.apache.flex.utils.Language.closure = function(fn, object, boundMethodName) {
+  if (object.hasOwnProperty(boundMethodName)) {
+    return object[boundMethodName];
+  }
+  var boundMethod = goog.bind(fn, object);
+  Object.defineProperty(object, boundMethodName, {
+    value: boundMethod
+  });
+  return boundMethod;
+};


Mime
View raw message