Fork me on GitHub
#clojurescript
<
2020-06-10
>
dnolen00:06:27

@jonas I haven't done any testing at all - but in theory it should work. You would have to run the bundler on your splits

dnolen00:06:47

experience reports welcome

raspasov02:06:53

7 years later, this runs great on a mobile device! 😃 cljs (http://swannodette.github.io/2013/08/02/100000-dom-updates/)

🙂 3
Schpaa11:06:22

I need an ordered set for clojurescript, which should I use?

Schpaa11:06:15

(something that preserves the insert order)

reefersleep13:06:51

I’ve recently learned that input type=number has some odd behaviour that does not gel well with e.g. Reagent. For example, since 42e3 is a valid js number, you are free to enter that into your input. However, even if e4e2e3e is not a valid js number, you are allowed to put it into your input field. Since it’s not a valid js number, the on-change function that you are normally relying on won’t fire, so you’ll end up with a browser state that has e4e2e3e and an atom state that doesn’t. (That’s my own reasoning, based on what I’ve witnessed.) Is there some general wisdom somewhere about using input type=number regarding such gotchas as the above somewhere on the internet? I tried googling for it, but didn’t find what I was looking for. Specifically, it seems to me that using input type=text instead and rolling your own validation (and whatever else behavior you need) seems to be the more appropriate solution in general, as you’ll be more in control of what happens and how it should look.

Stuart15:06:36

I'mhaving a problem getting a very basic reagent app to work. My deps.edn

{:deps {com.bhauman/figwheel-main {:mvn/version "0.2.8"}
        com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
        reagent {:mvn/version "1.0.0-alpha2"}}
 :paths ["src" "target" "resources"]}
My demo.cljs.edn
^{:css-dirs ["resources/public/css"]}
{:main todo-demo.main}
My folder structure looks like this:
.                                                                                                   
     ├── demo.cljs.edn                                                                                   
     ├── deps.edn                                                                                        
     ├── resources                                                                                       
     │   └── public                                                                                      
     │       └── index.html                                                                              
     ├── src                                                                                             
     │   └── todo_demo                                                                                   
     │       └── main.cljs   
My main.cljs:
(ns todo-demo.main
  (:require [reagent.core :as r]
            [reagent.dom :as rdom]))

(defn title []
  [:div
   [:p "Hello, World"]])

(defn app []
  [:div
   [title]])

(defn main []
  (rdom/render [app] (js/document.getElementById "app")))
I run it with
$ clj -m figwheel.main -m --build demo --repl
But I can't get it to display Hello World in a div. My index.html:

<html>
  <head>
    <!-- this refers to resources/public/css/style.css -->
    <link href="css/style.css" rel="stylesheet" type="text/css">
  </head>
  <body>
    <div id="app"></div>
	<!-- this refers to target/public/cljs-out/cruel-main.js -->
    <script src="cljs-out/demo-main.js"></script>
  </body>
</html>
Have I maybe missed what I need to call the main function for it to be called? I can do this at the repl from the docs:
(def app-element (js/document.getElementById "app"))
(set! (.-innerHTML app-element) "Hello, World!")
And I get Hello, World on the page.

bhauman15:06:07

@qmstuart if you open the devtools console in your browser what does it say?

Stuart15:06:00

This is the console output

thheller15:06:41

@qmstuart you are not calling the main fn anywhere. add <script>todo_demo.main.main();</script> in your html

👍 2
Stuart15:06:31

That did it!! Thank you 😄

👍 2
dpsutton15:06:51


<html>
  <head>
    <!-- this refers to resources/public/css/style.css -->
    <link href="css/style.css" rel="stylesheet" type="text/css">
  </head>
  <body>
    <div id="app"></div>
	<!-- this refers to target/public/cljs-out/cruel-main.js -->
    <script src="cljs-out/cruel-main.js"></script>
  </body>
</html>

bhauman15:06:38

the tutorial doesn’t encapsulate start in a main function

mengu16:06:42

it looks like versions after 1.10.520 broke IE

mengu16:06:36

the new one spits out a const eb in a and IE 11 does not support that

thheller16:06:09

no CLJS code outputs const anywhere. likely one of your JS dependencies?

mengu16:06:30

@thheller I don't think my dependencies are getting minified depending on my clojurescript version but I'll try to reproduce it in a clean repo

mengu16:06:43

@thheller, here's a repro way:

lein new figwheel repro
lein cljsbuild once min

mengu16:06:56

in the file you'll see function ha(a){const b=[];let c=0;for(const d in a)b[c++]=d;return b}

bhauman17:06:01

@mengu that output needs to be bundled

thheller17:06:19

run it with :pretty-print true :pseudo-names true in your compiler options to see where that is coming from

bhauman17:06:22

actually I take that back

thheller17:06:57

ah wait ... it probably is from the closure library

mengu17:06:00

and when I set the version as 1.10.520, no consts of any kind

thheller17:06:05

so try :language-out :es3 in your compiler options

mengu17:06:38

that worked

mengu17:06:52

looks like I've missed that change in the release notes

mengu17:06:05

apologies for taking your time @thheller & @bhauman

bhauman17:06:50

super easy to miss

mengu17:06:00

thanks again 🙂

dominicm21:06:19

What's my option(s) for REBL (or alike) in ClojureScript? Does the official cognitect REBL work with Cljs?

lilactown23:06:03

I think shadow-cljs inspect is moving towards that

lilactown23:06:35

I think a remote REBL makes a lot of sense. if I ever take a sabbatical it will be one of the projects I try and work on 😄

💯 1
lilactown23:06:28

is there a way to say, “run this at the end of the current tick?”

lilactown23:06:14

I don’t want to use setTimeout/rAF/promises because I want to do the work in the current tick

lilactown23:06:04

ah, actually Promise.resolve might do what I want