bhauman / devcards

Devcards aims to provide a visual REPL experience for ClojureScript
1.53k stars 116 forks source link

Project data from `:inspect-data` with `:projection` option #138

Closed dpsutton closed 6 years ago

dpsutton commented 6 years ago

Somtimes card state is a bit more verbose than what is actually interesting. This allows for a :projection option to manipulate the data for the edn printout. Function of a single arity should be passed the state atom.

(defcard reagent-support

  (dc/reagent re-bmi-component)
  re-bmi-data
  {:inspect-data true
   :projection (fn [bmi-data] :bmi)
   :frame true
   :history true })

This makes my life a bit nicer at the moment. I would like to add the ability to toggle the projection on and off so that one could see the entire data structure if so desired. At the moment you have to just comment out the :projection argument. I'll need to learn a bit more about the internals and the ui before I can do that though.

Let me know if you prefer a different option name. Also, I'm not sure how to extend validate-card-options to verify this, nor if there should be a bit more error handling in case the function does something wonky. You are very conscious of user experience and I don't want to negatively impact this.

Satisfies issue https://github.com/bhauman/devcards/issues/137

Example:

Before verbose

And After filtered

bhauman commented 6 years ago

This looks great, could you add to the docs as well?

http://rigsomelight.com/devcards/#!/devdemos.defcard_api

dpsutton commented 6 years ago

@bhauman pushed. I'm assuming you don't want committed changes to the out.js. Let me know if that's not correct

bhauman commented 6 years ago

I don't see the changes

dpsutton commented 6 years ago

ah sorry. renamed remotes and it didn't push. it should be there now @bhauman

bhauman commented 6 years ago

good stuff! Thanks!