Fork me on GitHub

seems weird. have you tried macroexpanding it in cljs?

Mitch Dzugan10:04:13

same error on attempting to macroexpand

Mitch Dzugan10:04:54

a full macroexpand fails but if I macroexpand-1 I get

(cljs.core/defprotocol MyProtocol (proto-method [b]))
which works fine if I then copy and paste that into my source. very odd


I could use a hand with understanding an issue with using cljsjs packages. I've now run the second time into an issue where I would like to use a symbol from the underlying package, but I just get an undefined error when I try.


Concretely: I require ["@date-io/date-fns" :as df] and then try to use df/DateFnsUtils, but this is apparently undefined.


Trying to use df/DateIODateFnsUtils also just gives an undefined.


I guess I simply don't understand cljsjs package usage.


@schaueho those are just externs. they are meant to prevent :advanced compilation from renaming them. the df is all you need? meaning it should have all the properties you might need?


Sort of ... In the end I want to use a different JS lib, material-ui-pickers (date/time pickers) and this expects to be handed over this DateFnsUtils constructor. I guess it's ultimately calling other functions from date-fns internally.


when I compare the date-io.ext.js contents above with the ones for the material-ui package (which I use without issues), then the latter defines all the various components / functions etc. as properties.


but that of course doesn't help me with understanding what I have to do to use the @date-io/date-fns package.

Mitch Dzugan17:04:38

I created a small repo that demonstrates this issue: This very simple macro

   (defmacro defprotom [proto-name fn-name fn-args]
     `(~(macros/case :clj 'clojure.core/defprotocol
                     :cljs 'cljs.core/defprotocol) ~proto-name
       (~fn-name ~fn-args))))
fails only in clojurescript running lein test-cljs will demonstrate the failure. If you comment out the usage of the macro it prints the result of macroexpand-1 the same thing which is strange because if you take that result and put it back in the file the test will pass. Appreciate any help this has been stumping me for several days now.

Mitch Dzugan19:04:10

For some reason this worked

   (defmacro defprotom [proto-name fn-name fn-args]
     `(~(macros/case :clj 'clojure.core/defprotocol
                     :cljs 'cljs.core/defprotocol) ~proto-name
       ~(clojure.core/list fn-name fn-args))))
not sure why but ill take it


anyone has a library to turn sentences like “every 2 weeks” into something useful to do math with? (e.g. would be a seq of dates of today + intervals of two weeks)


hehe I knew there had to be something out there nice thanks!


channels are basically queues


you cannot introspect them


the word introspect is a little confusing to me


You cannot see what’s in them without calling take.


You can’t even get the current length of a channel, much to my own frustration 🙂


are there situations where you can use these interchangeably?


channels and atoms?


not really, unless you’re using an atom as a queue


which is kind of an abuse of atoms


mmmh... makes sense


you could implement your own buffer if you really wanted something that would tell you the current size. you'd be using things inside .impl. ns's though so no guarantee on forward compatibility


they are used to convey values


In clojure, mutable state (e.g. atoms) contains values


but @potetm if a channel is not a buffered channel, then i'ts not really a queue right?

Alex Miller (Clojure team)18:04:32

unbuffered channels do have space for a single value, there is no buffer. they require both producer and consumer to show up at the same time to transfer the value directly from one to the other (this is called a "rendezvous" in other systems)


because we can only have a single value it it


it’s a very small queue


Even unbuffered, they offer pretty much the same semantics. Most importantly, asynchrony.


cool... thanks simple_smile... I have some more clarity on that now

bananadance 4
Mark Bailey18:04:54

(defn main-content []                                                                                                                                                                                                                     73   [:div                                                                                                                                                                                                                                   74    [:p "What we offer"]                                                                                                                                                                                                                   75    [:ul (fn []                                                                                                                                                                                                                            76           (doseq [xs (site-content :offerings)]                                                                                                                                                                                           77             [:li (xs :heading)]))]])

Mark Bailey18:04:30

okay! thank you!

🍷 4
Mark Bailey18:04:20

@U08E8UGF7 so, updated, the code looks like

(defn main-content []                                                                                                                                                                                                                        [:div
    [:p "What we offer"]
    [:ul (for [xs (site-content :offerings)]
               [:li (xs :heading)]
               [:li (xs :desc)]))]])
and it is only displaying the heading

Mark Bailey18:04:36

or rather the description

Mark Bailey18:04:48

should i be placing those <li>s in a vec?


user=> (do
         [:li :missed]
         [:li :returned])
[:li :returned]


so this explains why heading is not rendered


as it is not in the hiccup data


you have to figure out how to have ‘fragments’ returned

❤️ 4
Mark Bailey18:04:41

fragments?? never heard of those, lemme head to google


which is more than a single element

Mark Bailey18:04:23

you, sir, or madame, are a godsend! thank you so much!!

Mark Bailey18:04:02

working as expected now!


Awesome, cheers 🙂

Mark Bailey18:04:34

so, i am trying to build a dynamic <ul> that adds <li>s according to a datastructure that I have in my website

Mark Bailey18:04:58

so far, after many many attempts, i still cannot get those <li>s to work

Mark Bailey18:04:31

(def site-content {:main-header "Love and Labradorite"                    
                       :tagline "Love and Labradorite"
                     :offerings [{:heading "Tarot Reading ($15 and up)"
                                  :desc "30 minutes and up. Minimum of six cards maximum of 10 on a subject that you require guidance on."}
                                {:heading "Intuition Reading with Spirit Guidance ($30 and up)"
                                  :desc "Do you need guidance about career, love, or any other topic going on in your life? I can give you a full reading with spirit guidance on how to handle your current situation. This is my custome\
    r favorite."}
                                 {:heading "Mediumship ($60 and up)"
                                  :desc "Connect to a passed love ones to receive messages and closure."}
                                 {:heading "Reiki Distance Healing  ($25)"                                                                                                                                                                                                   :desc "Reiki is non-invasive and is used holistically to restore balance in mind, body and spirit while promoting the body's regenerative self-healing ability. Its healing energy connects us on an ene\    rgetic and spiritual level where the healing work is conducted."}]})

Mark Bailey18:04:10

there is the data structure