This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-08
Channels
- # announcements (7)
- # babashka (44)
- # beginners (162)
- # cider (22)
- # clara (11)
- # clj-kondo (14)
- # cljsrn (8)
- # clojure (91)
- # clojure-dev (24)
- # clojure-europe (6)
- # clojure-france (4)
- # clojure-italy (11)
- # clojure-nl (4)
- # clojure-spec (11)
- # clojure-uk (14)
- # clojurescript (92)
- # community-development (1)
- # core-logic (1)
- # cryogen (1)
- # cursive (6)
- # data-science (3)
- # datahike (3)
- # datomic (32)
- # degree9 (3)
- # dirac (3)
- # emacs (9)
- # eql (1)
- # events (1)
- # find-my-lib (1)
- # fulcro (67)
- # graphql (13)
- # helix (9)
- # jobs (1)
- # jobs-discuss (92)
- # leiningen (31)
- # malli (8)
- # meander (3)
- # news-and-articles (1)
- # off-topic (46)
- # pathom (2)
- # practicalli (1)
- # re-frame (52)
- # reitit (12)
- # shadow-cljs (40)
- # spacemacs (10)
- # sql (4)
- # xtdb (8)
If anyone would like to help me hack the cljs compiler, im adding native class support
@flyboarder woah nice!
not currently, I think this needs some real world testing first
yeah I have read it, my personal use case is on node.js with a project that requires I extend existing classes
nice. if it's any inspiration, here's the syntax I chose for helix (a react wrapper) for creating a React class:
(defcomponent MyClass
(foo [this]
,,,)
^:static (bar [this] ,,,))
That reminds me of om’s defui https://github.com/omcljs/om/blob/775f3adebde911988674f1bf179fd8b920031c8e/src/devcards/om/devcards/tutorials.cljs#L30
@lilactown this is the exact syntax I was also thinking!
or MyClass :implements SomeInterface
For this line:
(.val (js/jQuery (str "delivery" (:num-delivery-addresses db))) (:description suggestion))
I'm getting the following error:
Uncaught Error: [object Object] is not ISeqable
at Object.cljs$core$seq [as seq] (core.cljs:1226)
at re_frame$fx$do_fx_after (fx.cljc:74)
at Object.re_frame$interceptor$invoke_interceptor_fn [as invoke_interceptor_fn] (interceptor.cljc:71)
at Object.re_frame$interceptor$invoke_interceptors [as invoke_interceptors] (interceptor.cljc:109)
at Object.re_frame$interceptor$execute [as execute] (interceptor.cljc:204)
at Object.re_frame$events$handle [as handle] (events.cljc:65)
at Object.eval [as re_frame$router$IEventQueue$_process_1st_event_in_queue$arity$1] (router.cljc:179)
at Object.eval [as re_frame$router$IEventQueue$_run_queue$arity$1] (router.cljc:198)
at eval (router.cljc:146)
at Object.eval [as re_frame$router$IEventQueue$_fsm_trigger$arity$3] (router.cljc:169)
Why would that be?@pshar10 can you verify your brackets? looks like (:description suggestion)
is the context object jquery is expecting
@pshar10 is your db
an atom?
you might need to add @db
if the db object is an atom containing your map
i dont know much about your app so I am guessing at what the vars could be
the simple thing to do would be to replace it bit by bit
for all intents and purposes it's a parameter of a function, and within the function db is used
and figure out exactly which function is throwing
either :num-delivery-addresses
or :description
is operating on an object
not on a collection
so it’s attempting to access a js object as if it was a map
are you able to print each of these in-place of what is currently broken?
are you able to print the element you are selecting also?
there might be a difference between cljs and js strings though and the expression expects js ones, I don't know
well right now we dont know if (js/jQuery (str "delivery" (:num-delivery-addresses db))
<- this is broken
or if this is broken -> (.val elem (:description suggestion))
ok so it’s probably (:num-delivery-addresses db)
try deref’ing the db (:num-delivery-addresses @db)
if this db map is in an atom it will need to come out first
hm, im at a loss then, what happens when you print the db is it a straight clojure map?
The expression is valid but I think it's in the wrong place or something. That reframe expects some other ending to that function, I don't know.
what is it contained within?
The default implementation of weakmap
doesn't make a lot of sense in CLJS, right? As in, it works on identity, and not value. Is it true to say that underneath the hood, cljs doesn't try to "reuse" objects that have already been created with a particular value...? Hence, there's no way for a weakmap to know if a particular instance of a value can be discarded or not.
So a value added to a weak map, might be garbage collected and removed from the weak map if you lose reference to that object
(def ws (js/WeakSet.))
=> #'cljs.user/ws
(.add ws :hi)
=> #object[WeakSet [object WeakSet]]
(.has ws :hi)
=> false
(def k :hi)
=> #'cljs.user/k
(.add ws k)
=> #object[WeakSet [object WeakSet]]
(.has ws k)
=> true
@dazld all the JS collections only operate on object identity and in development keywords are recreated on time. in a release build you'd get the "expected" result since keywords are only created once.
but it would still run into issues if you get your keyword via dynamic constructed code (eg. edn, transit)
CLJS also has the same issue which is why identical?
doesn't work for keywords/symbols and they have their own keyword-identical?
variants
@U05224H0W Do you know of a reason why keyword literals are recreated in dev? Seems counter-intuitive at best.
the difference really is just a performance/code-size optimization. you should always treat keywords as-if you were in development
and this optimization you'd still do even if keywords were interned ... doesn't really change anything on that front
We're back at base 1 one then. Why not enable this optimization in dev as well? Would it somehow hinder the development?
now that I think about it the reason this is done is probably :advanced
. if you were to register a keyword in some global "registry" (eg. weakmap or just js object) then closure can never DCE any keyword
you cannot enable it in dev. in shadow-cljs its a closure compiler pass that optimizes the whole program at once
in regular CLJS it emits "forward" references in the code that are then created in a special namespace with special handling in the compiler as part of the build
in dev with REPL and stuff you cannot possibly know all the keywords that are going to be constructed
> then closure can never DCE any keyword
But we don't have DCE in dev either way. But I'm assuming that such a registry is populated after DCE. Which is probably not the case in :advanced
.
> you cannot enable it in dev. in shadow-cljs its a closure compiler pass that optimizes the whole program at once
Ah. Well, one can dream. :)
there is not much to dream about. you either have DCE for keywords or you gain the "convenience" of interned keywords. I'd rather have DCE.
I can't think of a good reason to not hoist constants in dev mode too. You could just hoist them to the referencing file, instead of one big file like you do for prod. (Assuming reload experience is the problem) @U05224H0W For DCE, couldn't you just switch all static references to keywords to new functions that find-or-create them (specificially)? E.g., :foo/bar => (find-or-create-foo-SLASH-bar)
Is there any good library support to traverse the DOM? The particular use-case I have is react-testing-library and accessing node collections, childrens, attributes and so on. The JS interop works, of course, but feels somewhat cumbersome.
@schaueho (tree-seq #(some? (.-children %)) #(array-seq (.-children %)) js/document)