Skip to content

Commit e3600e2

Browse files
committed
introduce runonce macro
this is a helper for https://github.com/binaryage/chromex-sample/issues/10
1 parent ddeff18 commit e3600e2

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/lib/chromex/support.clj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@
3636
(defn get-src-info [form]
3737
(meta form))
3838

39+
(defmacro runonce [& body]
40+
(let [code (cons 'do body)
41+
code-string (pr-str code)
42+
code-hash (hash code-string)
43+
name (symbol (str "runonce_" code-hash))]
44+
`(defonce ~name {:value ~code
45+
:code ~code-string})))
46+
3947
; -- miscellaneous ----------------------------------------------------------------------------------------------------------
4048

4149
(defn get-source-location [src-info]

0 commit comments

Comments
 (0)