clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
2020-12-14T13:54:24.303700Z

@jrychter Which React wrapper do you use? You should put a code block with an fuction example.

jrychter 2020-12-14T13:55:29.303900Z

Rum. And narrowing it down to a simple code block isn't easy. But I think I have a working theory — the functions get cached somewhere and they do reference an atom, just a different one, because each render creates a new one and they keep referencing the previous one.

2020-12-14T14:01:08.304100Z

For your component with the local state/atom, did you use defc or defcs ? https://github.com/tonsky/rum#components-local-state

2020-12-14T14:01:40.304400Z

> rum.core/defcs is used instead of rum.core/defc. It allows you to get hold of the components’s state in the render function (it will be passed as a first argument).

jrychter 2020-12-14T14:05:42.304600Z

Thanks Michael — I do know these things, this application has ~85k LOC and has been developed over the last 5 years or so. And yet — things still manage to surprise me sometimes.

jrychter 2020-12-14T14:07:17.304800Z

I now know that some components deep down do not get updated (keeping old closures) and using an atom does not help, unless that atom is part of component state, otherwise every render gets a different atom. Very hairy. I'm brute-forcing it by using rum/with-key to force updates.

2020-12-14T14:16:40.305Z

@jrychter ok, i didn't quite understand the request which is more complex than i initialy thought. Good luck.

jrychter 2020-12-14T14:20:32.305200Z

Thanks! I should have explained it better.

2020-12-14T18:12:16.306400Z

(cljs.analyzer.api/ns-resolve 'clojure.core 'map)

2020-12-14T18:14:05.307300Z

Any reason why that’s giving me a can’t deref null? Seems like the state it’s trying to use doesn’t exist?

clyfe 2020-12-14T18:23:25.307400Z

Where is is called from? env/compiler gets populated by the cljs compiler and makes such data visible at compile time, so that's info available in macros.

clyfe 2020-12-14T18:25:06.307600Z

(cljs.analyzer.api/ns-resolve 'cljs.core 'map)
Does that ^ yield anything?

currentoor 2020-12-14T19:25:26.310500Z

What is the JS equivalent of go-loop? AFAIK async/await are like go/<! respectively. But I can't think of something with the looping nature of go-loop.

phronmophobic 2020-12-14T19:46:00.312600Z

setTimeout with 0 as a delay will run some code at some point in the future . you can have a for/while loop in js with await statements, i believe

👍 1
p-himik 2020-12-14T19:46:15.312800Z

A self-recursive async function should be similar.

currentoor 2020-12-14T19:48:08.313400Z

@p-himik that won't blow the stack?

currentoor 2020-12-14T19:48:52.313900Z

i didn't know JS had tail recursion

p-himik 2020-12-14T19:50:27.314300Z

My knowledge of JS is limited - better check it rather than trust me. I think it shouldn't blow up the stack if you don't await the self-call. Otherwise, the setTimeout solution should work.

currentoor 2020-12-14T19:51:35.314700Z

got it, thanks!

william 2020-12-14T21:02:36.318300Z

there's something I don't like in the reagent code I'm writing, and I'd like to ask how this is commonly done: sometimes I pass to a child both an atom (maybe because I'm using a ref), and some concrete values that come from an atom in the parent. I don't like that they're not syntactically distinct. Do you usually prepend a ! to a variable denoting an atom?

Felix M 2020-12-14T21:06:42.319300Z

Hi,, what are my options for sprinkling a few reactive components in a server side rendered Clojure app without going full SPA.  I'm looking to have form inputs filter the the db and return the results client side without incurring a full page refresh. #beginners #programming-beginners x-post from #clojure where they recommended I post here

p-himik 2020-12-14T21:06:47.319400Z

re-com has a nice approach. Many arguments can be either atoms or concrete values. It check conditionally derefs them all.

🙌 1
2020-12-14T21:29:37.320Z

Ah that might be it, I was trying to call that at runtime