helix

https://github.com/Lokeh/helix
2020-01-31T17:31:45.196600Z

@lilactown just saw you merged my PR, thanks, btw. I started wondering if $$ macro is really needed, shouldn’t $ fall back to dynamic code when static codegen is not possible?

lilactown 2020-01-31T17:32:22.197300Z

the $$ is really only there for when you need to take it as a value

lilactown 2020-01-31T17:32:44.197900Z

people are using it way more than I ever imagined, but that’s AFAICT mostly due to my lack of documentation

2020-01-31T17:33:36.199Z

well, are you aware of the technique where you provide both macro and fn with the same name and compiler decides for fn if macro cannot be used? core lib uses this quite a lot

lilactown 2020-01-31T17:39:49.200300Z

yep, could go that route now. I was also hedging in case $ didn’t work for some reason, but it is pretty baked now

lilactown 2020-01-31T17:40:55.200800Z

I’m still pondering the kebab->camelCase proposal

lilactown 2020-01-31T17:42:03.201800Z

it’s really a question of what’s more confusing: the macros silently changing the actual API of your components, or having to mix kebab and camel and remember which to use where?

2020-01-31T17:45:30.202600Z

is it that hard? in cljs code you use only kebab, in js land you use camel, according to conventions in given language

2020-01-31T17:46:02.203100Z

but I agree, that it might look like a magic for someone new (not familiar with details how it works)

2020-01-31T17:47:28.204600Z

I would propse doing no conversion at all by default, and to have an easy opt-in for something like I proposed - not sure if you want to support both, e.g. because of documentation and maybe even greater confusion for newbies

2020-01-31T17:50:46.206Z

I’m still not done with my prototype code (didn’t find time), but I’d like to implement the opposite way during the weekened and start testing it on my codebase, I wonder if I find any issues with the approach

2020-01-31T17:51:41.206800Z

the implementation of the bean with custom key translation will be easy, I guess

lilactown 2020-01-31T18:23:45.212Z

I think in the happy path, always using kebab feels good because your code reads very consistently. in the sad path, though, or more complicated scenarios, it can get frustrating trying to figure out and debug when and why your code is changing underneath you. for instance, we recently built a fairly complex component at work using helix, that ended up doing some complicated stuff with cloning children prop manipulation. the dev that did this was new to helix (and CLJS), and there were a number of places where they got confused if they should e.g. use :class, :className . And it ended up depending on if they were creating the element or cloning the element.

lilactown 2020-01-31T18:24:52.213600Z

of course, providing a helix version of clone-element that also used the same props API as $ would help here. but it also complicated the debugging process, because it was opaque when and why certain props would change without reading and understanding helix’s source code

2020-01-31T18:24:55.213700Z

how was he able to get his hands on raw props not wrapped in the bean?

2020-01-31T18:25:12.214300Z

using raw function as component?

lilactown 2020-01-31T18:26:04.215200Z

they were using https://reactjs.org/docs/react-api.html#cloneelement to clone an already instantiated element with some new/changed props

lilactown 2020-01-31T18:27:04.215700Z

and reading props that were set on a child element

2020-01-31T18:28:08.216400Z

ok, these are valid cases where js convetions leak into cljs

2020-01-31T18:30:10.217400Z

but I think this could be mitigated simply exposing props-bean in public api, people doing interop-y stuff should be aware that they want to wrap js-land props with that bean

2020-01-31T18:30:46.218Z

but I understand that this might be too much to ask

lilactown 2020-01-31T18:37:32.218300Z

I mean, the current state is not ideal right now either

lilactown 2020-01-31T18:38:36.219500Z

depending on if you’re reading/cloning a helix component element, or a native element, and you want to override the class name, you will want to use either :class or :className 😵

2020-01-31T18:39:31.220500Z

well, even with native element I want to wrap it into props-bean, all cljs code should use cljs conventions

2020-01-31T18:39:45.220900Z

props-bean is kinda js->clj

2020-01-31T18:40:22.221500Z

actually this is my goal personally, to be able to write idiomatic cljs code all the time when I’m actually in cljs

1👍
2020-01-31T18:40:40.221800Z

no matter if component at hand came from helix or not

lilactown 2020-01-31T19:03:17.222400Z

could create some tools for manipulating props / children / etc.

1👍
2020-01-31T19:41:56.222900Z

@lilactown I think I screwed that displayName patch: https://github.com/Lokeh/helix/commit/a3ba54ce6c2fa222b4137cfa2e03a3247160d688

2020-01-31T19:42:30.223300Z

here I don’t return the object at the end

2020-01-31T19:42:57.223800Z

that’s why you had doto there

lilactown 2020-01-31T19:43:13.224Z

ah, I missed that

2020-01-31T19:46:01.224500Z

do you want me to do another PR or you fix it on your own?

2020-01-31T19:46:05.224700Z

just that doto is misisng