diff --git a/src/main/cljs/cljs/proxy.cljs b/src/main/cljs/cljs/proxy.cljs index c3ef55414..0940d472c 100644 --- a/src/main/cljs/cljs/proxy.cljs +++ b/src/main/cljs/cljs/proxy.cljs @@ -38,12 +38,17 @@ Note key-fn is only used for proxied ClojureScript maps. This function should map strings to the appropriate key representation. If unspecified, key-fn defaults to keyword. All maps - proxied from the same ctor fn will share the same key-fn cache." + proxied from the same ctor fn will share the same key-fn cache. + + A cache-fn may be suppled to override the default cache. This fn + should take key-fn and return a memoized version." ([] (builder keyword)) ([key-fn] + (builder keyword write-through)) + ([key-fn cache-fn] (js* "var __ctor") - (let [cache-key-fn (write-through key-fn) + (let [cache-key-fn (cache-fn key-fn) vec-handler #js {:get (fn [^cljs.core/IIndexed target prop receiver] (cond (identical? "length" prop) @@ -106,6 +111,9 @@ :else target))] __ctor))) +(def ^{:doc "Default proxy for maps and vectors."} + proxy (builder)) + (comment (def c (SimpleCache. #js {} 0))