This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-18
Channels
- # 100-days-of-code (2)
- # beginners (10)
- # boot (1)
- # calva (8)
- # cider (13)
- # cljdoc (7)
- # clojure (32)
- # clojure-uk (15)
- # clojurescript (9)
- # code-reviews (1)
- # cursive (8)
- # datomic (1)
- # emacs (1)
- # fulcro (9)
- # hoplon (4)
- # nrepl (1)
- # off-topic (30)
- # onyx (2)
- # re-frame (11)
- # reitit (3)
- # shadow-cljs (33)
- # tools-deps (3)
- # vim (5)
For the routing example given in the book, and in fulcro template, what is the reason for the route ident being [(:page props) :top]
? This seems to pollute the global props namespace with the naked names of each route, no?
@sooheon yes, but that’s exactly what idents do in a normalized DB, they put your data exactly two hops from the root of the database
don’t think of it as polluting a top level namespace, it much more like everything in a SQL database is two pieces of information away, table name and primary key, just like idents
also, in the book that is a very simple pedagogical example, you’re free to name your idents as you see fit
for example in my app i often use the namespace of the component’s file in the ident
I have a namespace called ucv.ui.wash-packages
where i define
(defsc WashPackageAdmin [this props]
{:query (fn []
[:kind
{::table (prim/get-query Table)}])
:ident (fn [] [::admin :tab])
:initial-state (fn [_] {:kind ::admin
::table (prim/get-initial-state Table {})})}
(div :.ui.container
...))
Then for app state, and anywhere outside of this namespace this gives me an ident
[:ucv.ui.wash-packages/admin :tab]
similar for a number of other routed components and sub-routers
so my routing tree definition looks like this
(def routing-tree
(r/routing-tree
(r/make-route :ucv.ui.wash-packages/admin
[(r/router-instruction :root/top-router [:ucv.ui.wash-packages/admin :tab])
(r/router-instruction :ucv.ui.wash-packages/admin-router [:ucv.ui.wash-packages/no-modal :tab])])
(r/make-route :ucv.ui.wash-packages/details
[(r/router-instruction :root/top-router [:ucv.ui.wash-packages/admin :tab])
(r/router-instruction :ucv.ui.wash-packages/admin-router [:ucv.ui.wash-packages/details :tab])])
(r/make-route :ucv.ui.wash-packages/new
[(r/router-instruction :root/top-router [:ucv.ui.wash-packages/admin :tab])
(r/router-instruction :ucv.ui.wash-packages/admin-router [:ucv.ui.wash-packages/new :tab])])
...))