This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-04-01
Channels
- # announcements (14)
- # beginners (6)
- # biff (6)
- # calva (3)
- # cider (7)
- # clojure (79)
- # clojure-europe (5)
- # clojure-norway (9)
- # cursive (9)
- # data-science (20)
- # datomic (3)
- # fulcro (9)
- # graalvm (15)
- # integrant (2)
- # introduce-yourself (2)
- # jobs (1)
- # lsp (7)
- # malli (5)
- # off-topic (130)
- # parinfer (11)
- # pedestal (11)
- # portal (1)
- # practicalli (4)
- # releases (3)
- # remote-jobs (1)
- # ring (8)
- # ring-swagger (30)
- # shadow-cljs (9)
- # sql (10)
- # tools-deps (8)
What is SPA
in fulcro-native-template
for ? can i just use APP
instead?
(defonce SPA (atom nil))
(defonce APP (-> (app/fulcro-app {:render-root! expo-root/render-root
:hydrate-root! (fn [& _])
:optimized-render! kr/render!})))
(reset! SPA APP)
The atom being in a ns by itself is a useful thing, though…it’s the whole point of having it, though you don’t technically need it
The reason for an atom in a ns by itself is so that you can configure the fulcro app with things from your application (say network stack helpers) and then put the app into the atom. The reason for this is that Clojure(script) doesn’t allow for circular ns references…so when you get to more detailed and big applications it’s just better to know that the “app atom” ns is safe to require everywhere
i.e.
(ns app.app-atom) (defonce SPA (atom nil))
is a ns that any other ns can require for any reason without any possibility of a circular require (including the one that defines the real app, so it can reset the value). As you expand your ns with the actual app in it and do things like configure the networking, RAD rendering, etc it gets more and more likely that you won’t be able to require that ns safely anywhere you might need direct access to the global app.