squint

rafaeldelboni 2025-03-20T11:19:35.501759Z

Hey quick question, is there any destructing option on squint for js object props?

rafaeldelboni 2025-03-20T11:20:38.408999Z

I think not, just found this issue https://github.com/squint-cljs/squint/issues/491

borkdude 2025-03-20T11:26:08.798599Z

can you give an example of what you mean by this

rafaeldelboni 2025-03-20T11:27:37.684269Z

I was searching for something like we can have with this lib on cljs https://github.com/applied-science/js-interop?tab=readme-ov-file#destructuring

borkdude 2025-03-20T11:28:04.040799Z

can you give a specific code example

borkdude 2025-03-20T11:28:24.762869Z

destructuring works in general

rafaeldelboni 2025-03-20T11:37:55.194089Z

yeah, I never dared to just try this with js/objects haha

(let [{{href :href} :location} js/document]
  href)
this just works, cool

borkdude 2025-03-20T11:38:53.469309Z

so you didn't dare to try it before asking? ;)

rafaeldelboni 2025-03-20T11:39:22.812359Z

Yeah, sorry I just took for granted because the xp in cljs

borkdude 2025-03-20T11:39:53.487499Z

took what for granted?

borkdude 2025-03-20T11:41:49.842069Z

that object destructuring didn't work? squint is designed around JS objects so it better work

rafaeldelboni 2025-03-20T11:46:16.123919Z

I took for granted that wouldn't work, for some reason, I always thought that destructuring would only work for clojure maps

borkdude 2025-03-20T11:46:32.590649Z

squint doesn't have clojure maps

borkdude 2025-03-20T11:46:37.545129Z

it's all JS objects

rafaeldelboni 2025-03-20T11:48:29.182969Z

make sense

borkdude 2025-03-20T11:51:33.502619Z

hope that didn't scare you ;)

rafaeldelboni 2025-03-20T11:53:25.681019Z

Maybe I'm just still to attached with the old cljs, because this doesn't work there right?

(let [{{href :href} :location} js/document]
  href)
I always used js-interop to be able to do something similar, but never stopped to think that squint is so thin that doesn't have any diff a map than a js/object

borkdude 2025-03-20T11:54:35.266429Z

that is the major difference between squint and #cherry: squint doesn't have immutable persistent data structures, it just works with the JS objects / arrays directly

🆒 1
yogthos 2025-03-20T23:25:21.632629Z

I was just playing with preact, and it's really tiny compared to react, I'm using jotai for state management and the whole bundle is just 29kb https://github.com/yogthos/squint-preact-example

👍 1
🤏 1
🎉 8