-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify & clean up viewers #53
Conversation
@zampino @philomates if either of you want to look over this before I merge it, please do. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
#?@(:cljs [IFn | ||
(-invoke [this x] ((:f this) x)) | ||
(-invoke [this x y] ((:f this) x y))])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so on the :clj
side we no longer want to implement IFn
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right.
src/nextjournal/clerk/viewer.cljc
Outdated
@@ -153,7 +145,7 @@ | |||
|
|||
(def elide-string-length 100) | |||
|
|||
(declare with-viewer*) | |||
(declare with-viewer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line can be removed completely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, dropped it in ac9dee5.
@@ -219,42 +211,16 @@ | |||
{:pred string? :render-fn (quote v/string-viewer) :fetch-opts {:n 100}} | |||
{:pred number? :render-fn '(fn [x] (v/html [:span.tabular-nums (if (js/Number.isNaN x) "NaN" (str x))]))}]) | |||
|
|||
(defn process-fns [viewers] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
Simplify the viewer api by dropping the macros and requiring users to quote the
:render-fn
. This should make it explicit and less magic as to what part of the viewers is evaluated on the JVM and what is sent over the wire to run in the browser.