Fork me on GitHub
#clojurescript
<
2018-01-21
>
lilactown00:01:49

@alex340 could you show an example usage of your macro? I’m struggling:

(defstyled header :h1 "color: blue;")

(defn hello-world []
  [:div {:style {:font-family "sans-serif"}}
   [header (:text @app-state)]
   [:h3 "Edit this and watch it change!"]])
outputs:
core.cljs:305 Uncaught Error: No protocol method ICollection.-conj defined for type string: Hello world!

lilactown00:01:03

hmm, I see. by changing it to [header {} (:text @app-state)] it now works as expected

lilactown00:01:38

OK, I’ve gotten up and running with shadow-cljs and it’s easier than I expected

ajs06:01:42

according to this: https://clojurescript.org/about/differences

Currently ClojureScript numbers are just JavaScript numbers
Yet, I recently learned that JS does not have an integer type, all numbers are 64-bit floats. So how is CLJS int type implemented if its numbers are just JS numbers?

tbaldridge06:01:56

@ajs CLJS doesn't have int types...

tbaldridge06:01:29

(type 1) in cljs returns number

tbaldridge06:01:25

(defn int
  "Coerce to int by stripping decimal places."
  [x]
  (bit-or x 0))

ajs06:01:17

i see, the functions int? and integer? were leading me to believe it did, but i see now they are not what I think they are

mjmeintjes11:01:43

Hi. I've been struggling with converting the following javascript into clojurescript, and hoped someone here can help me:

let Inline = Quill.import('blots/inline');
class BoldBlot extends Inline { }

mike_ananev11:01:50

Is it interesting for clojurescript?

ackerleytng13:01:30

with this,

(defn clear-button []
  [:a {:style {:visibility (if (str/blank? (@app-state :url))
                             "hidden"
                             "visible")}}
   [:span.icon.is-right.is-small {:on-click #(.log js/console "hello")}
    [:i.fas.fa-times]]])
reagent doesn't render the onClick - when i inspect this button, onClick isn't even there, but if it's
(defn clear-button []
  [:a 
   [:span.icon.is-right.is-small {:on-click #(.log js/console "hello")}
    [:i.fas.fa-times]]])
then everything works fine. Why might this be?

ackerleytng13:01:05

hold on - chrome's inspector doesn't show <span onClick="blah"> as i was expecting it to

ackerleytng13:01:35

so i'm guessing that the span just got rendered below another element and can't receive the "click"

juhoteperi13:01:31

@ackerleytng React never places the event handlers on DOM. It handles the events internally.

Vincent Cantin13:01:29

@ackerleytng He means that it registers the event programmatically, that's why it does not show up on the span element in the dom displayed by the inspector.

Vincent Cantin13:01:59

Your span may not receive the click if it occupies no space on the web page. Double-check that, add some text inside your span tag.

Vincent Cantin14:01:21

You may try to set pointer-events: none; on the style of :i.fas.fa-times and see if it helps.

ackerleytng14:01:47

thanks so much!

Vincent Cantin14:01:31

You're welcome.

ackerleytng14:01:07

I'm pretty sure it's something to do with layering

ackerleytng14:01:22

i'm using bulma and the cross was actually an icon, something like https://bulma.io/documentation/form/input/#with-font-awesome-icons

ackerleytng14:01:04

when i right click on the cross and click inspect, chrome highlights the input and not the span, so i guess bulma might have hidden the cross below

ackerleytng14:01:48

i switched to using a button, as in https://bulma.io/documentation/form/general/#form-addons so that fixed it

justinlee18:01:34

The discussion of (.method js/object) vs (js/object.method) comes up a bunch and people seem to favor the former. But just to be clear: the latter form is passed through to javascript without being subject to advanced compilation, correct? In dealing with external libraries (without extern declarations), it seems like this is a big advantage.

justinlee18:01:25

wait i’m confused. what does that demonstrate?

justinlee18:01:53

oh. nevermind i got it

justinlee18:01:17

only object["method"] would be safe

justinlee18:01:31

back to using cljs-oops 🙂

darwin18:01:20

btw. (.toString #(.method js/object 1 2 3)) produces exactly the same js code, so (I assume) there is no difference when the code gets passed to google closure compiler

justinlee18:01:50

i forgot that the evil happens after clojurescript is done

rauh18:01:59

@lee.justin.m Just enable externs inference and this will be covered automaticallly

justinlee18:01:51

@rauh i guess. the documentation on externs inference is not exactly reassuring. particularly the part where it says (Alpha) in the title

rauh18:01:55

Well you can always inspect the generated externs in your source folder and see if what's in there. Unless you have thousands you can quicky verify it.

rauh18:01:09

It's working pretty well for most people.

justinlee18:01:05

my problem is that it’s just me working on this project. i can’t be going off into the deep end of compiler internals, or trying to figure out some subtle bug with externs, or trying to translate from es7 code. using cljs-oops is dead simple and it will definitely work, so that’s kind of what I’m leaning towards

darwin18:01:01

cljs-oops also has dev-time diagnostics, which could help catch some class of mistakes

justinlee18:01:13

all of the documentation on inference and externs and so forth tend to assume that I understand what on earth google closure compiler is doing, and how its type system works. i really don’t want to know about that if i don’t have to

darwin18:01:16

on the other hand, cljs-oops could slow down your compilation times (it uses macros heavily)

justinlee18:01:41

thankfully for me that is the least of my worries. i care only about correctness and developer power

darwin18:01:54

personally I’m in the same boat, also cljs compilation is pretty slow anyways, so during development I have to rely on incremental compilation setup anyways

lilactown20:01:20

I’m trying to understand how to use shadow-cljs with the macchiato framework that yogthos wrote

lilactown20:01:14

I’m not quite understanding how figwheel knows how to start/stop the http server in the template

thheller20:01:22

@lilactown happy to help in the #shadow-cljs chan

lilactown20:01:31

ah OK, i’ll switch there 🙂

alexisvincent22:01:57

With a clj + cljs project developed in cider where we want to share code, should it be 2 Lein projects or one? If one, how do I specify client vs server dependencies?

lilactown23:01:16

@alexisvincent you could do either one

lilactown23:01:01

client dependencies can be mixed with server dependencies - when you compile the projects, the server will only import the dependencies it needs. same with the client