Skip to content
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

Allow 3rd party trace #149

Open
mike-thompson-day8 opened this issue Feb 10, 2018 · 1 comment
Open

Allow 3rd party trace #149

mike-thompson-day8 opened this issue Feb 10, 2018 · 1 comment

Comments

@mike-thompson-day8
Copy link
Contributor

mike-thompson-day8 commented Feb 10, 2018

At the moment, re-frame and reagent are the only sources of trace. How about we allow the application programmer to produce their own trace, and have it folded into the stream for later inspection.

Hmm. Strictly speaking this is a re-frame issue more than a re-frame-trace issue, I think, but it makes sense to track it here.

Perhaps have tracing macro utilities which make it even easier for programmers to produce trace.

As an example, consider this dlet macro:

;; From e.g. https://github.com/scottjad/uteal
(defmacro dlet
  "let with inspected bindings"
  [bindings & body]
  `(let [~@(mapcat (fn [[n v]]
                     (if (or (vector? n) (map? n))
                       [n v]
                       [n v '_ `(println (name '~n) ":" ~v)]))
                   (partition 2 bindings))]
     ~@body))

which allows use like:

(dlet  [a  (something :a)      ;; note use of `dlet` instead of `let`
        b  (f "hello")]
   ... )

Now imagine that dlet produced trace instead of using println . And imagine that the trace is recorded against the event handler (or subscription) in which this dlet was used. Maybe call it tlet for trace let.

@kimo-k
Copy link
Contributor

kimo-k commented Jun 16, 2023

Maybe this could be a single tap handler that observes re-frame's state.

Any macros would simply wrap parts of your code with (tap>). That could easily be its own concern, not dependent on 10x.

To record not just an evaluation, but the literal form as well, is a cool idea. I think shadow-cljs does that.

(defmacro tlet
  "let with tapped bindings"
  [bindings & body]
  `(let [~@(mapcat (fn [[n v]]
                     (if (or (vector? n) (map? n))
                       [n v]
                       [n v '_ `(tap> [(name '~n) ~v)]]))
                   (partition 2 bindings))]
     ~@body))

@mike-thompson-day8

@kimo-k kimo-k assigned kimo-k and unassigned kimo-k Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants