clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
2020-06-27T08:40:30.408900Z

Does anyone have or know of any examples of using spec with reagent views?

Joe Lane 2020-07-06T15:08:28.445900Z

Hey @jayzawrotny, I'm a little late to the party, but I found this blog post to be very apropos https://juxt.pro/blog/cljs-apps

2020-07-06T15:10:04.446400Z

Thanks @lanejo01

borkdude 2020-06-27T09:18:42.409400Z

@jayzawrotny I do have one example from a commercial app I've worked on for the last few years:

(s/fdef dre.components.widget/widget
  :args
  (s/and
   (s/cat
    :opts
    (s/keys
     :req-un [::title ;; title in header
              ::content ;; Contents to show in widget. It must be a Hiccup
              ;; vector. Widget does not support varying arguments in
              ;; content, they are for initialization only.
              ]
     :opt-un [::id ;; unique identifier for widget (page wide, not app
              ;; wide)
              ::icon ;; icon to show in header
              ::widget-class ;; CSS class
              ::collapsable? ;; If it can be collapsed
              ::init-collapsed? ;; initialize the widget in a collapsed
              ;; state?
              ::help ;; help contents which are shown in modal
              ::controls ;; Arbitrary component rendered in the
              ;; header. What it does is up to you.
              ::selections ;; coll of dropdown/tabs
              ::dropdown ;; convenience option, singular version of
              ;; selections with
              ;; {:type :dropdown, :id :dropdown} by default
              ::tabs ;; convenience option, singular version of selections
              ;; with {:type :tabs, :id :tabs}
              ::loading? ;; Whether or not to display a loading indicator
              ::locked? ;; Whether or not content modifications are possible
              ::menu ;; menu
              ::on-will-unmount]))
   (fn [{:keys [opts]}]
     (if-let [unexpected
              (seq (apply dissoc opts expected-keys))]
       (do
         (warn "Unexpected options" unexpected)
         false)
       true))))

borkdude 2020-06-27T09:20:49.409800Z

@jayzawrotny This is about the only Reagent component I've spec-ed because it has so many options

borkdude 2020-06-27T09:22:39.410200Z

Not sure if it's useful, but this is the app: http://covid19.doctorevidence.com/ (this is a free preview of it)

2020-06-27T18:29:03.410900Z

Thanks @borkdude this really helps!