Fork me on GitHub
#helix
<
2020-05-15
>
lilactown14:05:24

any thoughts from folks?

Aron14:05:08

for me the reverse problem is more interesting, I don't need spec for checking dev time code, I need it to generate data

dominicm14:05:22

I don't think hs needs to wrap def. I think we just need some kind of spec which does {"helix/props" <spec>} as a js obj.

Aron14:05:40

some? :)

dominicm14:05:08

there's ops, etc. I don't remember the spec thing I mean.

lilactown14:05:05

I want to at least expose the cdef because it allows helix to change the way it handles props w/o messing with people’s specs

lilactown14:05:53

since it’s hidden behind the cdef macro

lilactown14:05:31

helix.spec/def would be there just for the removal of specs at release

dominicm14:05:40

Same thing is achieved by (hs/props map?) where map? is user spec.

dominicm14:05:45

You can change as much as you like.

lilactown14:05:04

hmm i’m not sure

lilactown14:05:47

(s/fdef greeting :args (s/cat :props (hs/props map?)))

lilactown14:05:11

it’s kind of a mouthful

lilactown14:05:21

but maybe it would be good to have both

lilactown14:05:45

it also assumes that greeting is a function component

lilactown14:05:54

and I am wondering how I might extend this to class components

lilactown14:05:04

probably not important for the first iteration

lilactown14:05:19

i use classes so rarely :)

Aron14:05:01

apart from error boundaries, I don't know why would you use them

lilactown14:05:10

@ashnur once you can spec a component, creating generators isn’t too far off

Aron14:05:47

thanks, I realized this along the way, way after I wrote it down : | : )

👍 4
dominicm15:05:37

I wouldn't say it's much more of a mouthful than the equivalent without hs: (s/fdef greeting :args (s/cat :props (hs/props map?))).

dominicm15:05:47

Leverage the knowledge people already have about spec :)

Aron15:05:33

deez peepl

lilactown15:05:25

yeah, I want to introduce the minimal amount of API. seems good!

lilactown15:05:03

next thing to think about is how to compose component specs, e.g.:

;; somehow get props spec of a specific component
(s/def ::greeting-props (hs/props-of greeting))

(s/def ::greeting-container-props
  (s/keys [::greeting-props]))

(s/fdef greeting-container
  :args (s/cat :props (hs/props greeting-container-props)))

(defnc greeting-container
  [{:keys [greeting-props]}]
  ($ greeting {& greeting-props}))

Aleed17:05:33

Fulcro has guardrails (https://github.com/fulcrologic/guardrails) * not sure if it helps spec JS object but it has a similar goal of only being for development time and not impact prod bundle size (haven’t used it though, but might be a good reference)

lilactown17:05:59

yeah, definitely inspirational