Fork me on GitHub
#clojurescript
<
2021-10-22
>
borkdude06:10:07

Yes, @raymcdermott is trying to use the defn-args spec

genRaiy08:10:56

the specs in cljs.core.specs.alpha

michihuber10:10:18

My clojurescript app gets stuck in an infinite loop in Chrome 95 or higher. 94 is fine, as are FF and Safari. Anybody else experiencing this? Any hints on how I can debug this? (probably not cljs related, but no idea where to start) Any pointers much appreciated!

p-himik10:10:13

Open the DevTools, navigate to the Scripts tab, and press the pause button.

p-himik10:10:44

If you do indeed have a proper infinite loop it should be relatively easy to debug it from there.

michihuber11:10:24

pausing doesn't work, it disables the button (after I click it), but doesn't manage to actually pause execution

p-himik12:10:21

Huh, I've never seen that behavior before. Is that app available publicly somewhere?

p-himik12:10:41

Either as a deployed version of a repository with instructions on how to run it locally.

michihuber13:10:39

it was caused by an absolutely positioned element – layouting issue

michihuber13:10:23

will work around it 😅 thank you for the pointers

p-himik13:10:04

So the browser was stuck while trying to compute the layout? Definitely sounds like a browser bug. :)

dnolen14:10:02

@borkdude but it's a .cljc file so why can't it be required directly? Or did I miss something?

borkdude14:10:47

because the .cljs file is in front of it

dnolen14:10:11

I repeat, how does that in anyway prevent you from loading a .cljc file directly? 🙂

dnolen14:10:40

or the answer might be that they have the same name, and the .cljc file is semantically .clj

dnolen14:10:09

as in you can't load it because of extension load order

borkdude14:10:20

yes, that is what I'm trying to say

dnolen14:10:53

I guess they could just be collapsed - but ok yeah no workaround for now

borkdude14:10:25

yeah I think it could be a single .cljc file

genRaiy17:10:43

@dnolen are the specs enforced during compilation?

dnolen17:10:13

yes I thought they were @mfikes added support for this some time ago

genRaiy17:10:45

cool. It would be nice to have them at runtime too. Do we make an issue on the JIRA?

Alex Miller (Clojure team)17:10:31

as always, you can put this on http://ask.clojure.org and I'll make a ticket out of it

genRaiy18:10:14

seems like it already was requested

genRaiy18:10:24

3 years ago

genRaiy18:10:56

maybe spec2 will do the honours 🙏:skin-tone-3:

dnolen17:10:20

patch also welcome, this not a super-priority thing at the moment for me

mfikes17:10:15

Yes, my memory is that compile-time specs are supported 🙂

genRaiy17:10:43

161 | (defn foo 123)
-------^------------------------------------------------------------------------
Syntax error macroexpanding cljs.core/defn.
Call to cljs.core/defn did not conform to spec.
-- Spec failed --------------------

  (... 123)
       ^^^

should satisfy

  vector?

genRaiy17:10:47

so yup 🙂

lilactown17:10:33

would including the core specs in cljs at runtime increase the production bundle size at all?

dnolen17:10:06

well specs can't be DCEd anyway

dnolen17:10:16

you would get the specs only if you require the specs

lilactown17:10:18

yeah, that's the reason i asked - wasn't sure if the specs got required by cljs.core or something

dnolen17:10:29

no, they don't

Rob Haisfield20:10:58

I would really like to use Ethers.js to interact with the Ethereum network from ClojureScript. Could anyone make a solid ClojureScript wrapper for the library? I’m willing to commission it if you DM me. I never learned JavaScript, so I don’t feel comfortable attacking this on my own. I would love it if the JS knowledge could be abstracted away in the ClojureScript wrapper. https://docs.ethers.io/v5/

emccue21:10:50

i’m not convinced there is a utility to a CLJS wrapper. The kind of things you would do would be • Translate back and forth from #js {:arg val} and {:arg val} • Re-expose methods on objects as functions in namespaces

emccue21:10:20

and in doing that you need to carry over or write brand new documentation

emccue21:10:41

all so you can do (ethers-providers/web-3-provider js/ethereum) instead of (ether.providers.Web3Provider. js/ethereum) and (provider/get-signer provider) instead of (.getSigner provider)

Rob Haisfield22:10:56

Got it… thanks for the feedback there. Clojure is the only programming language I've worked with so I just didn't know if a ClojureScript wrapper with new documentation would make it so I don't need to learn JavaScript to work with it in ClojureScript

lilactown22:10:12

to debug any difficulties in development you would likely need to understand the JS semantics

lilactown22:10:27

you can only get so far doing Clojure without understanding the basics of Java. with ClojureScript, arguably it's more important to understand the JS under the hood since I find it a bit leakier

Simon12:10:13

I have also thought about interacting with the EVM (ethereum virtual machine) from Clojure. Perhaps a more interesting way to approach it—is by using the Ethereum LLL (Low-level Lisp-like Language), which would be similar to Clojure.

john21:10:56

Not sure how different Ether.js is from web3, but it does seem to be a recent take on interfacing with eth from cljs

Rob Haisfield22:10:50

Yeah I have, from what I had heard ether.js was just a more approachable base library than web3.js

👍 1
metehan21:10:49

when I try to send a file to server instead of file I am sending a string which is [object File] what I am doing wrong here:

(defn get-file-input []
  (-> (.getElementById js/document "infile")
      .-files first))

(defn upload-file []
  (http/post ""
             {:form-params {:key1 [1 2 3]
                            :key2 "value2"
                            :file (get-file-input)}}))

(defn ui
  []
  [:div {:style {:font-family "Tahoma, Verdana, Sans-serif"
                 :font-size "larger"
                 :text-align :center}}
   [:h1 "Upload your file"]
   [:input#infile {:type :file}]
   [:button {:on-click #(upload-file)} "Upload"]])

p-himik22:10:59

What is http? Also, don't use .getElementById. Instead, store the file in an atom in a :on-change handler attached to the :input and pass the value of that atom to upload-file. Avoid global references.

metehan22:10:46

http is [cljs-http "0.1.46"] now I am converting to local variable

p-himik22:10:19

I'm 90% sure that for file uploading you have to use multipart data. cljs-http has an example right in its README.

metehan22:10:43

I followed read-me of r0mank’s cljs-http library here -> https://github.com/r0man/cljs-http

p-himik22:10:02

Please don't @ people without real need. Mere mentioning should be done without @. Yes, I understand that you followed the README of the library. But you didn't follow it exactly. The file uploading examples all use :multipart-params whereas your code uses :form-params.

metehan22:10:16

I didn't know @ is pinging in threads too

metehan22:10:34

I don't use slack often sorry

p-himik22:10:46

That's alright. Right, just confirmed - you can't use :form-params for file uploading since that argument is explicitly turned into a string:

(assoc :body (generate-query-string form-params))

metehan22:10:22

thank you very much it solves all the problem

👍 1