Skip to content

Commit

Permalink
Support callback and compiler options together in render fn
Browse files Browse the repository at this point in the history
  • Loading branch information
Deraen committed Nov 8, 2022
1 parent 7729370 commit c01ee72
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/reagent/dom.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@
(render comp container tmpl/default-compiler))
([comp container callback-or-compiler]
(ratom/flush!)
(let [[compiler callback] (if (fn? callback-or-compiler)
(let [[compiler callback] (cond
(map? callback-or-compiler)
[(:compiler callback-or-compiler) (:callback callback-or-compiler)]

(fn? callback-or-compiler)
[tmpl/default-compiler callback-or-compiler]
;; TODO: Callback option doesn't make sense now that
;; val is compiler object, not map.
[callback-or-compiler (:callback callback-or-compiler)])

:else
[callback-or-compiler nil])
f (fn []
(p/as-element compiler (if (fn? comp) (comp) comp)))]
(render-comp f container callback))))
Expand Down

0 comments on commit c01ee72

Please sign in to comment.