helix

https://github.com/Lokeh/helix
dominicm 2020-04-22T12:24:15.315500Z

Why does $ use &, rather than merge?

Aron 2020-04-22T12:42:45.316Z

Dunno, I am constantly tripping over it even as we speak 🙂 core.cljs:5383 Uncaught Error: No item & in vector of length 2

Aron 2020-04-22T13:26:00.316400Z

I really have no way how to debug this

Aron 2020-04-22T13:26:20.316900Z

I am baffled. I know what the problem is, but I don't know how to solve it in a general way, without using empirical programming.

Aron 2020-04-22T13:33:39.317300Z

ok, so I actually have to do a merge externally and then spread the merge

Aron 2020-04-22T13:33:57.317800Z

I think that will work, but I am getting the feeling that there is a better way to do it : )

dominicm 2020-04-22T13:34:54.318100Z

Hmm interesting.

Aron 2020-04-22T14:37:13.318500Z

the reason being that sometimes what I want to merge is null, and it throws

Aron 2020-04-22T15:41:29.318800Z

what should I do if I want to document my components?

lilactown 2020-04-22T16:03:40.319500Z

@dominicm it’s to allow some perf enhancements at macro time

dominicm 2020-04-22T16:04:49.321800Z

@lilactown could the same performance be achieved by a fn that takes a cljs map and a list of maps and has a return hint set as js obj?

lilactown 2020-04-22T16:05:38.322400Z

I’m not sure what that would achieve yet

lilactown 2020-04-22T16:05:42.322600Z

($ {:foo "bar" :baz 123}) macroexapnds to (.createElement react #js {:foo "bar" :baz 123})

lilactown 2020-04-22T16:07:24.324Z

$ will rewrite a map in the first position. if it’s not a map literal, it can’t distinguish between props and an arbitrary expression that returns a react element

lilactown 2020-04-22T16:08:19.324700Z

($ foo bar) is ambiguous, so it requires runtime checks. ($ (foo {:bar "baz"})) is also ambiguous

lilactown 2020-04-22T16:09:13.325400Z

I see what you’re saying, maybe you could add some special type hinting. but it couldn’t be ^js, since a React Element is also a POJO

lilactown 2020-04-22T16:12:12.325500Z

you can add docstrings to components

đź‘Ť 1
Aron 2020-04-22T16:37:43.326300Z

I think I will try a custom macro that doesn't try to guess but requires explicit arguments

Aron 2020-04-22T16:39:02.327800Z

like ($$ (can-return-stringforelement-or-component) (can-return-hash-or-nil-for-props))), children is part of props anyway, I have no problem having to pass them explicitly as such

Aron 2020-04-22T16:39:40.328400Z

in fact, instead of nil i would do a default {children:[]} for good measures and composability 🙂

Aron 2020-04-22T16:48:44.329100Z

another thing I just realized, while in cljs I can use strings as keys for hashmaps, I can't always do the same for components

dominicm 2020-04-22T17:19:05.329800Z

Possible feature idea: ($ "div.foo.bar") to reclaim some glorious reagent convenience.

đź‘Ť 1
Aron 2020-04-22T17:29:41.330100Z

that's the same as className="foo bar" ?

Aron 2020-04-22T17:29:48.330300Z

i never used reagent

dominicm 2020-04-22T17:30:04.330500Z

Yeah.

Aron 2020-04-22T17:42:18.331300Z

well, my classnames are mostly defined dynamically or pre-defined anyway. no one should write classnames by hand 🙂 I should know, I was a site-builder for 7 years