diff --git a/frontend/src/uxbox/util/mixins.clj b/frontend/src/uxbox/util/mixins.clj index ac3091445..fd0fd0ad0 100644 --- a/frontend/src/uxbox/util/mixins.clj +++ b/frontend/src/uxbox/util/mixins.clj @@ -2,7 +2,7 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; -;; Copyright (c) 2016 Andrey Antukh +;; Copyright (c) 2016-2017 Andrey Antukh (ns uxbox.util.mixins (:require [rum.core :as rum] @@ -43,9 +43,11 @@ (defmacro defc [& args] (let [[render doc mixins cname] (parse-defc args)] - `(def ~cname ~doc (rum/build-defc ~render ~mixins ~(str cname))))) + `(def ~cname ~doc (uxbox.util.mixins/lazy-component rum/build-defc ~render ~mixins ~(str cname))))) (defmacro defcs [& args] (let [[render doc mixins cname] (parse-defc args)] - `(def ~cname ~doc (rum/build-defcs ~render ~mixins ~(str cname))))) + `(def ~cname ~doc (uxbox.util.mixins/lazy-component rum/build-defcs ~render ~mixins ~(str cname))))) + + diff --git a/frontend/src/uxbox/util/mixins.cljs b/frontend/src/uxbox/util/mixins.cljs index 6696706a6..131a512e5 100644 --- a/frontend/src/uxbox/util/mixins.cljs +++ b/frontend/src/uxbox/util/mixins.cljs @@ -42,6 +42,12 @@ ([initial key] (rum/local initial key))) +(defn lazy-component + [builder render mixins display-name] + (let [ctor (delay (builder render mixins display-name))] + (fn [& args] + (apply @ctor args)))) + (def mount rum/mount) (def static rum/static) (def ref-node rum/ref-node)