This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-23
Channels
- # announcements (3)
- # aws (2)
- # babashka (31)
- # beginners (14)
- # calva (14)
- # cider (4)
- # clj-kondo (1)
- # clojure (24)
- # clojure-europe (18)
- # clojure-gamedev (4)
- # clojure-nl (3)
- # clojure-norway (23)
- # clojurescript (24)
- # core-typed (23)
- # data-science (9)
- # datomic (1)
- # emacs (15)
- # events (4)
- # gratitude (3)
- # introduce-yourself (1)
- # leiningen (9)
- # lsp (65)
- # membrane (39)
- # music (1)
- # nbb (1)
- # obb (8)
- # reitit (17)
- # releases (1)
- # tree-sitter (2)
- # vim (28)
- # xtdb (3)
Hey everyone, I have a table:
(map (fn [{:keys [name updated_at]}]
[table-row
[table-cell name]
[table-cell updated_at]])
(:selected-folder/forms data))
Inside the (:selected-folder/forms data), this is how it looks like
[{:name F1, :updated_at nil, :theme_data nil} {:name Untitled Form, :updated_at nil, :theme_data nil}] (for instance)
HOW DO I DO sorted-map-by where it sorts the data either ascending or descending based on the :name KEY?
Thanks, appreciate all the help in advanceit seems that it is a seq/vector instead of a map. So you can use directly sort
and its derivatives.
(sort-by :name (:selected-folder/forms data)) ; asc
(sort-by :name > (:selected-folder/forms data)) ; des
If im merging two vectors, you know how can I sort-by "2" keys, in this case, :product_name and :name ? THANKS
If each donโt exist in the other one, you can or them #(or (:name %) (:product_name %))
instead of :name
Another question, I am importing two maps to display on an MUI table. This is how I do it:
(map (fn [{:keys [product_name thumbnail id template_id last_send_count last_accessed_date product_description]}]
[table-row
[table-cell {} product_name]
[table-cell {} "workspace-name"]
[table-cell {} last_accessed_date]])
(if (nil? @sorted-data) (:selected-folder/projects data) @sorted-data))
(map (fn [{:keys [name id theme_data count updated_at form_id]}]
[table-row
[table-cell {} name]
[table-cell {} "workspace-name"]
[table-cell {} updated_at]])
(:selected-folder/forms data))
Any ideas how do I "merge" both maps into one so when I want to sort the data, it sorts both maps ascending/descending order. Thanksas I said in the other thread they are vectors so just use concat: (concat data1 data2)
Hi,
is it possible to get the ns-alises
of a cljs namespace calling a macro? e.g.
(defmacro ns-aliases [] (ns-aliases *ns*))
Currently I get the empty map, though printing *ns*
indicates that it is indeed the calling cljs namespace.
correction, this does work if I'm calling from cljc.
test.cljs
(println (other-ns/ns-aliases)) => {}
test.cljc
(println (other-ns/ns-aliases)) => {dev.other-ns other-ns}
Macros are run in Clojure (Java), even if it is used in cljs. If you want it at runtime you might want to use google closure api.
I'm trying to understand how to use thrown? with cljs.test. Now i get this error
FAIL in (col-ref-to-doc-path) (anr/fire/admin_test.cljs:24:9)
Creating CollectionReference with a document path
expected: (thrown? (f/col [:tests :test-id]))
actual: nil
My test code is:
(deftest col-ref-to-doc-path
(testing "Creating CollectionReference with a document path"
(is (thrown? (f/col [:tests :test-id])))))
I'm not sure what to put as the first argument to thrown?Any form that is expected to throw. thrown?
accepts a body that the function handling thrown?
wraps in a try-catch block.
In your case, seems like that call to f/col
didn't throw.
Oh, sorry - the body comes as the last item in the (thrown? ...)
form. The first item is the exception type - what you'd put after catch
.
yes, it successfully tried with js/Error
So if you'd write
(try
(some-code)
(catch :default e
...))
then in a test it would be (is (thrown? :default (some-code)))
.ah, I'll try :default too
yep that works too
Anyone know how to use pseudo elements in Garden?
I am trying to use a ::before
psuedo-elem.
(css [:p [garden.selectors/before {:content "'mytext'"}]])
Returns "p ::before {\n content: 'mytext';\n}"
But not sure how to connect element to psuedo-element in rule so it renders like this:
p::before {content: "mytext";}
This works:
(css [:p:before {:content "'mytext '"}])
=> "p:before {\n content: 'mytext ';\n}"
[:p (g.sel/& (g.sel/before)) {:content "'mytext '"}]
or
[(g.sel/p (g.sel/before)) {:content "'mytext '"}]
and of course you can always just do
["p::before" {:content "'mytext '"}]