This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-03-03
Channels
- # aws (9)
- # beginners (5)
- # calva (5)
- # cljdoc (7)
- # cljsrn (3)
- # clojure (50)
- # clojure-greece (3)
- # clojure-uk (96)
- # clojurescript (18)
- # community-development (2)
- # core-logic (3)
- # cursive (4)
- # datomic (7)
- # emacs (3)
- # figwheel-main (3)
- # fulcro (5)
- # luminus (4)
- # mount (2)
- # nrepl (11)
- # onyx (6)
- # portkey (1)
- # qlkit (3)
- # re-frame (6)
- # shadow-cljs (33)
- # sql (8)
- # test-check (18)
- # yada (3)
I have another really basic question about yada and bidi, but I couldn't find it anywhere. Bidi allow to assign identifiers to URIs, which is great, so I have created routes data like this:
(def routes
["" [["" :page/index]
["/css/" :resource/css]
["/js/" :resource/js]
[true :routes/no-match]]])
Next, I have created a map from these identifiers to yada resources:
{:page/index (y/as-resource (io/resource "public/index.html"))
:resource/css (y.resources-resource/new-resources-resource "public/css/")
:resource/js (y.resources-resource/new-resources-resource "public/js/")
:routes/no-match (y/as-resource nil)}
But what is the idiomatic way to join these together to create a single yada handler? Currently I am using this, not sure how to change it:
(y/listener
[""
[["" (y/as-resource (io/resource "public/index.html"))]
["/css/" (y.resources-resource/new-resources-resource "public/js/")]
["/js/" (y.resources-resource/new-resources-resource "public/js/")]
[true (y/as-resource nil)]]]
{:port port})
This is correct. You can associate each yada resource with an id. This is done via the :id key, which you can specify in custom resources and assoc into builtin resources. Then yada/path-for and yada/url-for will work.
That makes sense. I already have :id key associated with each resource, but how I do the remaining steps? And how I use resources in the listener? Can I access them via the key?
That makes sense. I already have :id key associated with each resource, but how I do the remaining steps? And how I use resources in the listener? Can I access them via the key?