This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-21
Channels
- # announcements (51)
- # asami (5)
- # babashka (25)
- # babashka-sci-dev (26)
- # beginners (33)
- # calva (10)
- # clj-kondo (51)
- # clj-yaml (99)
- # clojure (96)
- # clojure-australia (3)
- # clojure-berlin (5)
- # clojure-europe (151)
- # clojure-norway (58)
- # clojurescript (20)
- # cursive (13)
- # datalevin (1)
- # datomic (19)
- # docker (6)
- # emacs (55)
- # events (1)
- # fulcro (50)
- # gratitude (8)
- # juxt (7)
- # leiningen (5)
- # malli (6)
- # membrane (1)
- # nbb (28)
- # off-topic (22)
- # pathom (7)
- # polylith (20)
- # portal (1)
- # reagent (37)
- # reitit (2)
- # releases (2)
- # reveal (32)
- # scittle (34)
- # shadow-cljs (46)
- # testing (10)
- # tools-deps (33)
- # xtdb (18)
Hi all. Is there a clever way of sorting by a javascript value such as goog.date.Date? I currently have (sort-by #(-> ^Date % :t_ms_event/date .getTime) my-sequence-of-items) but it is brittle, doesn't handle nil values. I guess I need a comparator that can handle that type? If it makes a difference, I'm using Fulcro.
If you replace that ->
with some->
it should handle nil values just fine. Apart from that, there's nothing wrong in your approach, although I find it strange that you annotate %
with ^Date
(which should probably be ^js/Date
) and then extract :t_ms_event/date
from it.
Thanks @U2FRKM4TW ! It's a goog.date.Date which I am importing so it would work, but the hint is in the wrong place so well spotted. PS enjoyed your recent podcast!
Ah, right. But that hint is useless anyway - it's basically a documentation for you, unless you see the compiler complaining about .getTime
(which it shouldn't).
And thanks. :)
How can i use apply on a constructor eg (apply new js/Date date-arr)
<- doesn't work. also doesn't work (apply js/Date. date-arr)
(let [bound-constructor (.. js/Function bind (apply js/Date date-arr))]
(new bound-constructor))
or something like that.Whoaa that's pretty rad
I should learn JavaScript some day
Does anyone knows how to avoid multiple repetitive refers? E.g. if I have a Material UI lib and want to refer all of the components in different source files.
I want to bundle icons into one big .cljs
file and MUI components into another one and just :use
or :refer
them.
Currently, as it seems to me, it is impossible to do.
Yeah, we can use it. But in "ideal" world it would be great just to :refer :all and forget about prefix
it’s like single letter var names, it’s annoying - I used to do this too years ago - no more
Ah, well, maybe I'll arrive there at some point. :) But so far it feels just fine and s
for spec seems to be kinda stuck in the community as well.
sure for stuff like spec
ok, but for a lot of namespaces you’re not doing yourself any favors IMO
Maybe we're actually on the same note here - I'm using them only for very specific "low-level" namespaces, with a particular alias always representing a particular namespace within a particular project.
E.g. in one of the projects r
is always reagent.core
(third-party, global) and i
is always my.project.ui.icons
(project-specific).
I definitely don't use r
as well for my.project.reagent-stuff
or using x
for my.project.ns1.x
and my.project.ns2.x
.