Fork me on GitHub
#clojurescript
<
2020-09-09
>
ozzloy02:09:26

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/

ozzloy02:09:13

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

ozzloy02:09:19

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

ozzloy02:09:38

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

ozzloy02:09:44

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

ozzloy02:09:07

in pure clojurescript

dpsutton03:09:52

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

ozzloy03:09:51

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

Josef Richter08:09:24

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?

plexus08:09:53

sounds like a question for #shadow-cljs

thheller08:09:34

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

Josef Richter08:09:44

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

thheller08:09:02

what does the browser console say?

Josef Richter08:09:25

breaking_bad_quotes.core.init is not a function

Josef Richter08:09:40

<script>breaking_bad_quotes.core.init();</script> this one fails basically

thheller08:09:06

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

thheller08:09:14

did you maybe change the namespace in your code?

Josef Richter08:09:26

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

thheller08:09:57

and the watch compiled fine?

Josef Richter08:09:14

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.

thheller08:09:51

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

thheller08:09:11

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

thheller08:09:52

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

thheller08:09:07

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

thheller08:09:20

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

Josef Richter08:09:12

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

thheller08:09:47

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 Richter08:09:59

ok gimme a sec

Josef Richter09:09:22

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

thheller09:09:42

well .. there is no init fn?

Josef Richter09:09:53

oh I’m a fucking idiot

Josef Richter09:09:07

I was following the tutorial too literally and accidentally remove it

Josef Richter09:09:23

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

Josef Richter09:09:50

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

grounded_sage17:09:53

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

isak17:09:49

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

isak17:09:19

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

👍 3