This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-01
Channels
- # announcements (6)
- # beginners (68)
- # calva (5)
- # cider (3)
- # clara (1)
- # clojure (49)
- # clojure-europe (24)
- # clojure-nl (2)
- # clojure-norway (28)
- # clojure-seattle (1)
- # clojure-uk (5)
- # clojurescript (3)
- # conjure (5)
- # core-typed (6)
- # data-science (1)
- # datalevin (3)
- # datascript (3)
- # datavis (1)
- # datomic (19)
- # events (2)
- # fulcro (6)
- # gratitude (1)
- # helix (6)
- # hyperfiddle (19)
- # joyride (6)
- # lsp (20)
- # music (1)
- # nbb (12)
- # pathom (2)
- # pedestal (10)
- # re-frame (3)
- # reitit (3)
- # ring (5)
- # shadow-cljs (26)
- # yamlscript (17)
I also asked in datascript, but now I think it is more shadow-cljs related.
I am passing the function includes?
to datascript.
(d/q '[:find [(pull ?e ?pattern) ...]
:in $ ?sf ?pattern includes?
:where
[?e :person/firstname ?f]
[(includes? ?f ?sf)]
[?e :person/id ?i]]
db search-firstname pattern includes?)
This works in development, but returns []
in production compiled with shadow-cljs in a webworker. What do I have to do to the function so it works in advanced compilation? ^:export seems not to be it.This works:
(d/q `[:find [(~'pull ~'?e ~'?pattern) ...]
:in ~'$ ~'?sf ~'?pattern
:where
[~'?e :person/firstname ~'?f]
[(~includes? ~'?f ~'?sf)]
[~'?e :person/id ~'?i]]
db search-firstname pattern)
don't know much about how datascript works internally, maybe it expects parameters to all start with a ?
hey 👋 I have three little helper functions:
(defn js-append [^array array val] (.concat array #js [val]))
(defn js-add-at [^array array idx val] (.toSpliced array idx 0 val))
(defn js-remove-at [^array array idx] (.toSpliced array idx 1))
I originally didn't type hint array
and got a externs inference warning, so added ^array
. that made the warning go away. on production, though, js-append
works fine but js-add-at
and js-remove-at
try to invoke array.$toSpliced$
instead of array.toSpliced
. my questions:
1. why does the hinting work for concat and not for toSpliced? newer function?
2. when should I use ^array vs. ^js? ^js
makes the code compile correctly.
3. is this a shadow or clojurescript thing? I'm assuming shadow has its own externs inference logic for some reasonoh yeah, last year it seems. I assumed all green on caniuse meant it was ancient, but browsers seem to be adopting stuff quickly nowadays
default externs come from https://github.com/google/closure-compiler/tree/master/externs
I have a file data.json
that I'd like to inline into my build, is there a way to do this using :require
? I'm using :js-provider :import
I also noticed that the :import
option is not documented here: https://shadow-cljs.github.io/docs/UsersGuide.html#js-provider
Not sure if it should be?
it is documented here https://shadow-cljs.github.io/docs/UsersGuide.html#_third_party_tool_integration since that is the only target it works in
Okay, was just wondering since this is so easy with tools like vite. But it's actually not that small so I'll just load at runtime 🙂