Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(ns simple.core
(:require [reagent.core :as r]
[re-frame.core :as rf]))
(fn [_ _]
{:loading? true}))
(fn [db _]
(println "toggle")
(update db :loading? not)))
(fn [db _]
(-> db
(defn report-iframe
{:reagent-render (fn [loading?]
[:iframe {:src ""
:style {:display (if loading? "none" "block")
:width "100%"
:height "500px"}
:component-did-mount #(println "report-iframe-did-mount")}))
(defn report [loading?]
;; Note that when the surrounding div below is removed, the iframe component is mounted multiple times...
[:div (when loading?
[:div "Loading..."])]
[report-iframe loading?]])
(defn ui
(let [loading? (rf/subscribe [:loading?])]
[:button {:on-click #(rf/dispatch [:toggle-loading])}
"Click me"]
[report @loading?]]))
;; -- Entry Point -------------------------------------------------------------
(defn ^:export run
(rf/dispatch-sync [:initialize])
(r/render [ui]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.