Fork me on GitHub
#fulcro
<
2024-04-01
>
Fit Opene05:04:18

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)

tony.kay13:04:38

single-page app

tony.kay13:04:03

symbols are just symbols. use what you like, of course

tony.kay13:04:40

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

tony.kay13:04:10

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

tony.kay13:04:32

putting them in the same ns would defeat this purpose, and is non-sensical

tony.kay13:04:14

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.

tony.kay13:04:02

This is me trying to prevent a future headache for you..but if you read the presence of this atom as a thing “fulcro needs” for some reason, then you’ve definitely missed the point 😄

🙏 2
Fit Opene13:04:56

Thank you so much for your enlightening explanation! It has truly shed light on many aspects for me. Oftentimes, it's only when we facing problems that we truly grasp the reasons behind certain actions. I really appreciate your guidance!