You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a relatively easy fix. The following code will work as long as the cards don't share the same root UI node:
(defmacro untangled-app
"Embed an untangled client application in a devcard. The `args` can be any args you'd
normally pass to `new-untangled-client` except for `:initial-state` (which is taken from
InitialAppState or the card's data in that preferred order)"
[root-ui & args]
(let [s (symbol (str (name root-ui) "-application"))]
`(devcards.core/dom-node
(fn [state-atom# node#]
(defonce ~s (atom (untangled.client.core/new-untangled-client :initial-state state-atom# ~@args)))
(reset! ~s (untangled.client.core/mount (deref ~s) ~root-ui node#))
; ensures shows app state immediately if you're using inspect data and InitialAppState:
(js/setTimeout (fn [] (swap! state-atom# assoc :ui/react-key (untangled.client.util/unique-key))) 1000)))))
If we wrap that in a defuntangled-card macro we can leverage the unique symbol there to fix this.
Need to change the macro to do something more like in the om next helpers:
bhauman/devcards@234a91d
The text was updated successfully, but these errors were encountered: