clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
ozzloy 2020-09-09T02:03:26.408300Z

how do i clear a form input field? i'm trying (gdom/setTextContent temp-input "") but that does not work. following this tutorial: https://www.learn-clojurescript.com/section-2/lesson-15-capstone-temperature-converter/

ozzloy 2020-09-09T02:16:13.409700Z

weird, (set! (.-value temp-input) "") clears the input field if i do it in the repl, but not when i put it in a function in a file

ozzloy 2020-09-09T02:20:19.410300Z

same with (set! (. temp-input -value) ""). repl yes, file no

ozzloy 2020-09-09T02:41:38.411200Z

never mind. it was a pebkac. i was not reloading stuff correctly because i used the atom wrong

ozzloy 2020-09-09T02:49:44.411600Z

now that that works, i'm curious if this is "right" way to do it?

ozzloy 2020-09-09T02:50:07.412Z

in pure clojurescript

dpsutton 2020-09-09T03:27:52.413600Z

If you’re managing the Dom yourself yeah that’s the way to go. Often cljs web apps are react based apps where the ui state is derived from the current state

ozzloy 2020-09-09T03:33:51.414300Z

cool. yeah, this tutorial is just on clojurescript so far, react comes soon, i think

Josef Richter 2020-09-09T08:35:24.416400Z

hi folks, I was doing a quick tutorial on cljs+reagent, everything worked fine, but when I reload browser, it will just show “Shadow-cljs rocks!” now instead of the app. the app is started with shadow-cljs watch app and I tried to restart this too, but it doesn’t help. any advice, please?

Josef Richter 2020-09-09T08:35:52.416500Z

this is the tutorial I was following https://www.rockyourcode.com/tutorial-clojurescript-app-with-reagent-for-beginners-part-1/

plexus 2020-09-09T08:41:53.417Z

sounds like a question for #shadow-cljs

thheller 2020-09-09T08:42:34.417200Z

just look for Shadow-cljs rocks! in your code and see what that is 😛

Josef Richter 2020-09-09T08:43:44.417400Z

@thheller that’s the default content of the index.html. the <app> tag content is not being replaced by (cl)js for some reason..

thheller 2020-09-09T08:44:02.417600Z

what does the browser console say?

Josef Richter 2020-09-09T08:45:25.417800Z

breaking_bad_quotes.core.init is not a function

Josef Richter 2020-09-09T08:45:40.418Z

&lt;script&gt;breaking_bad_quotes.core.init();&lt;/script&gt; this one fails basically

thheller 2020-09-09T08:47:06.418200Z

just that or also a 404 on the .js file or so?

thheller 2020-09-09T08:47:14.418400Z

did you maybe change the namespace in your code?

Josef Richter 2020-09-09T08:48:26.418600Z

the main.js returns 200, seems ok. no 404 anywhere

thheller 2020-09-09T08:49:57.418800Z

and the watch compiled fine?

Josef Richter 2020-09-09T08:50:14.419Z

namespace not changed. the weird thing is it worked, but it broke down on browser refresh. watch seems to be working fine, no compilation errors.

thheller 2020-09-09T08:50:51.419200Z

any error in the browser console BEFORE "is not a function"

thheller 2020-09-09T08:51:11.419400Z

must be something happening that breaks the loading of the code. assuming that the names are otherwise all correct.

Josef Richter 2020-09-09T08:52:12.419600Z

no other errors in console. see screenshot https://www.dropbox.com/s/lcw9cy1n6appskp/Screenshot%202020-09-09%20at%2010.51.46.png?dl=0

thheller 2020-09-09T08:52:52.419800Z

hmm that looks like you are maybe calling the function too early?

thheller 2020-09-09T08:53:07.420Z

is the script tag loading the JS coming after the actual call?

thheller 2020-09-09T08:53:20.420200Z

btw the call should probably be removed entirely and use :init-fn in your config instead

Josef Richter 2020-09-09T08:54:12.420400Z

yes, it’s right underneath it.. but I didn’t really touch anything there. it’s mostly code generated by lein new shadow-cljs breaking-bad-quotes +reagent

Josef Richter 2020-09-09T08:54:44.420600Z

it’s this brief example https://www.rockyourcode.com/tutorial-clojurescript-app-with-reagent-for-beginners-part-1/

thheller 2020-09-09T08:55:47.421Z

I do not know what you did or didn't do. if you share the code I can probably tell you whats wrong. otherwise I'm just guessing which isn't very useful it seems.

Josef Richter 2020-09-09T08:55:59.421200Z

ok gimme a sec

Josef Richter 2020-09-09T09:00:22.421400Z

this is the code, I’ve been making changes only in core.cljs and adding deps in shadow-cljs.edn https://github.com/josefrichter/breaking_bad_quotes_test/blob/master/src/breaking_bad_quotes/core.cljs

thheller 2020-09-09T09:00:42.421700Z

well .. there is no init fn?

Josef Richter 2020-09-09T09:01:53.422300Z

oh I’m a fucking idiot

Josef Richter 2020-09-09T09:02:07.422500Z

I was following the tutorial too literally and accidentally remove it

Josef Richter 2020-09-09T09:02:23.422700Z

and was stupid enough not to realize that the init() that I’m calling is not there

Josef Richter 2020-09-09T09:02:50.422900Z

@thheller sorry for wasting your time, thank you for your help though!

grounded_sage 2020-09-09T17:37:53.424800Z

Does the Closure compiler have a way to handle Longs? This library seems to suggest so https://www.npmjs.com/package/long. But i am not that familiar with Closure Compiler

isak 2020-09-09T17:49:49.425Z

The Closure library has this type: goog.math.Long

isak 2020-09-09T17:50:19.425200Z

It is used by some libraries in the ecosystem, like transit

👍 1