mirror of
https://github.com/penpot/penpot.git
synced 2025-05-21 22:56:10 +02:00
Make components lazy by default.
This commit is contained in:
parent
c65e13a31f
commit
491d91b1ee
2 changed files with 11 additions and 3 deletions
|
@ -2,7 +2,7 @@
|
||||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
;; 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/.
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2016-2017 Andrey Antukh <niwi@niwi.nz>
|
||||||
|
|
||||||
(ns uxbox.util.mixins
|
(ns uxbox.util.mixins
|
||||||
(:require [rum.core :as rum]
|
(:require [rum.core :as rum]
|
||||||
|
@ -43,9 +43,11 @@
|
||||||
(defmacro defc
|
(defmacro defc
|
||||||
[& args]
|
[& args]
|
||||||
(let [[render doc mixins cname] (parse-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
|
(defmacro defcs
|
||||||
[& args]
|
[& args]
|
||||||
(let [[render doc mixins cname] (parse-defc 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)))))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,12 @@
|
||||||
([initial key]
|
([initial key]
|
||||||
(rum/local 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 mount rum/mount)
|
||||||
(def static rum/static)
|
(def static rum/static)
|
||||||
(def ref-node rum/ref-node)
|
(def ref-node rum/ref-node)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue