helix

https://github.com/Lokeh/helix
Aron 2020-04-17T09:54:45.201500Z

๐Ÿฆ†

Aron 2020-04-17T17:08:44.206900Z

If I want a set of components that I can reuse with dynamically configured values (so not reuse by hand, but right now I have a hashmap with keywords as keys and Components as values, but I made the mistake to just do {:typename #($ SelectInput {:pre "defined" :pro "ps" :& %)} which makes the props js values so it's a mess)

Aron 2020-04-17T17:10:05.208100Z

I figured I can just ($ (keyword-for-component the-above-hashmap) {:dynamic config}) But it's not this simple

Aron 2020-04-17T17:10:11.208400Z

should I try to use macros instead?

lilactown 2020-04-17T17:16:28.208800Z

I think that the $ expects a symbol in the first position

lilactown 2020-04-17T17:18:07.209700Z

whatโ€™s wrong with:

(defnc ConfiguredSelectInput
  [props]
  ($ SelectInput {:pre "defined" :pro "ps" :& props}))
?

lilactown 2020-04-17T17:18:58.210Z

this might help too: https://github.com/Lokeh/helix/issues/41

Aron 2020-04-17T17:23:55.210800Z

Nothing wrong with it, just when I use it, the {:key value} stuff is wrapped in #js, I might've read about this in the docs

Aron 2020-04-17T17:24:23.211100Z

Oh, I misread the question, let me think about your suggestion

Aron 2020-04-17T17:28:16.211400Z

Yeah, that issue is what I was remembering, but couldn't find it ๐Ÿ˜„

Aron 2020-04-17T17:38:21.212Z

But you are right, seems that I over-engineered it (although engineering is not the right word), I also confused :& with &

lilactown 2020-04-17T17:42:47.212300Z

you may use either :& or &

Aron 2020-04-17T17:51:42.212700Z

Hmm, so I didn't confuse it, it's something worse ๐Ÿ˜„

Aron 2020-04-17T18:55:44.213800Z

@lilactown figured out why it didn't work ๐Ÿ˜„ I was doing ($ CompName {:somekey { :nestedkey value & restprops}})

Aron 2020-04-17T18:56:03.214100Z

I guess I need merge for that

lilactown 2020-04-17T19:16:09.214400Z

thatโ€™s right, it only does a shallow merge

Aron 2020-04-17T20:04:34.215300Z

So, I found a situation where :& and & still don't seem to be the same:

(defcard AssetSelect
  "Select Asset type from the list"
  (fn [state _]
    ($ AssetSelectControl {:set-asset-type (fn [asset-type] 
                                             (swap! state assoc :asset-type asset-type))
                           :& @state}))
  state
  {:inspect-data true
   :history true
   :frame false
   :heading false}) 

Aron 2020-04-17T20:05:00.215900Z

this puts the state under the key :&, but if I use &, then it merges

Aron 2020-04-17T20:05:36.216300Z

state is just (def state (atom {}))

Aron 2020-04-17T20:05:52.216700Z

so I can share state between devcards

lilactown 2020-04-17T20:10:23.217Z

are you using the latest version of helix?

Aron 2020-04-17T20:15:16.217200Z

0.0.10

Aron 2020-04-17T20:49:35.219500Z

https://github.com/ashnur/helix-q made a minimal repo and was able to reproduce it

Aron 2020-04-17T20:50:02.219900Z

I suspect I am doing something wrong : )

Aron 2020-04-17T20:51:34.220100Z

https://github.com/ashnur/helix-q/issues/1

lilactown 2020-04-17T21:05:46.220400Z

found the bug!

lilactown 2020-04-17T21:05:49.220600Z

thanks for reporting

Aron 2020-04-17T21:12:20.221300Z

It was more of a case of asking for help, but I am glad it was not entirely selfish : )