From fb9c395bb1ab470c7fa8371dd055cefefb6d4c39 Mon Sep 17 00:00:00 2001 From: beta Date: Thu, 3 Sep 2015 01:09:38 +0800 Subject: [PATCH] Support server side rendering --- src/Cursor.js | 2 ++ src/util.js | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Cursor.js b/src/Cursor.js index e2fda10..0ea23ab 100644 --- a/src/Cursor.js +++ b/src/Cursor.js @@ -76,4 +76,6 @@ Cursor.build = build; Cursor.debug = false; +Cursor.dispose = util.clearCache; + module.exports = Cursor; diff --git a/src/util.js b/src/util.js index 01a968c..f76f63d 100644 --- a/src/util.js +++ b/src/util.js @@ -107,8 +107,8 @@ function refToHash (cmp) { } } +var cache = {}; function memoizeFactory (resolver) { - var cache = {}; function memoize(func) { return function () { var key = resolver ? resolver.apply(this, arguments) : arguments[0]; @@ -120,6 +120,12 @@ function memoizeFactory (resolver) { return memoize; } +function clearCache() { + cache = {}; + refsCache = {}; + cacheIdIndex = 0; +} + module.exports = { getRefAtPath: getRefAtPath, deref: deref, @@ -136,5 +142,6 @@ module.exports = { isEqual: isEqual, union: union, omit: omit, - find: find + find: find, + clearCache: clearCache };