Search code examples
clojurescriptreagentluminus

Execute function once element is shown


In a reagent app created using luminus via

lein new luminus asdf +cljs

How can I execute a function once an element, say :div.container in the snippet below, has been shown?

(defn about-page []
  [:div.container
   [:div.row
    [:div.col-md-12
     "this is the story of asdf... work in progress"]]])

Solution

  • I just read the friendly manual :) and found that the luminus generated app is no different from standard reagent.

    Changing above about-page function as follows does the trick. about-page-rendered is

    (defn about-page-render []
      [:div.container
       [:div.row
        [:div.col-md-12
         "this is the story of asdf... work in progress"]]])
    
    (defn about-page-rendered []
      (do-what-ever-is-necessary))
    
    (defn about-page []
      (r/create-class {:reagent-render about-page-render
                       :component-did-mount about-page-rendered}))