bhauman / devcards

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

Feature: Support functions that return data as the main object #38

Closed holyjak closed 9 years ago

holyjak commented 9 years ago

Currently I can pass a fn that returns a React component to a devcard. It would be nice if I could pass a function that returns just data and those were rendered using the edn renderer:

(devcard plain-fn #(identity %) {:key "val"})

Motivation

While developing a function, I want to see its output. I could use REPL but then I need to manually run the fn. Using a devcard would be more automatic - and more cool. But admittedly, this is a very low priority "maybe nice to have" so I am not sure the added complexity is worth it.

bhauman commented 9 years ago

Well I'm wondering if I understand your use case correctly, but the works fine:

(defn square-range [& args]
  (map (fn [x] (* x x)) (apply range args)))

(defcard square-range-example
    (square-range 10))

You can edit the square range function and see the results as you work on it.

bhauman commented 9 years ago

And you can do this as well:

(defcard example-func
  ((fn [a] (+ a 1)) 50))
holyjak commented 9 years ago

Good point, thanks!