any thoughts from folks?
for me the reverse problem is more interesting, I don't need spec for checking dev time code, I need it to generate data
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.
some? :)
there's ops, etc. I don't remember the spec thing I mean.
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
since it’s hidden behind the cdef
macro
helix.spec/def
would be there just for the removal of specs at release
Same thing is achieved by (hs/props map?)
where map?
is user spec.
You can change as much as you like.
hmm i’m not sure
(s/fdef greeting :args (s/cat :props (hs/props map?)))
it’s kind of a mouthful
but maybe it would be good to have both
it also assumes that greeting
is a function component
and I am wondering how I might extend this to class components
probably not important for the first iteration
i use classes so rarely :)
@ashnur once you can spec a component, creating generators isn’t too far off
thanks, I realized this along the way, way after I wrote it down : | : )
apart from error boundaries, I don't know why would you use them
yep same
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?)))
.
Leverage the knowledge people already have about spec :)
deez peepl
yeah, I want to introduce the minimal amount of API. seems good!
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}))
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)
yeah, definitely inspirational