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

Changed rx-debug to debug-rx as it's actually called. #15

Merged
merged 1 commit into from
Nov 21, 2014

Conversation

luxbock
Copy link

@luxbock luxbock commented Nov 20, 2014

Maybe it should be the other way around? I'm also wondering if rather than having debug-rx be a wrapper around a call to rx, it should rather act like rx does but also output debug-info to the console? It's a small change but I think adding -debug at the end of rx to turn on debugging would be easier than adding a separate wrapper around it.

@luxbock
Copy link
Author

luxbock commented Nov 20, 2014

I haven't tried this, but something like this should work, I think:

(defmacro debug-rx [& body]
  (let [dgb-str (str "rx-debug: " (pr-str &form))]
    `(let [dbg-str# ~dbg-str
           res#
           (binding [freactive.core/*do-trace-captures*
                     (fn
                       ([] (println dbg-str# ": starting capture"))
                       ([c#] (println dbg-str# "captured :" c#)))]
             (freactive.core/rx* (fn [] ~@body) false))
           invalidation-cb#
           (fn [k# r#] (println dbg-str#
                                "notifiying invalidation watches:"
                                (cljs.core/keys (.-invalidation-watches res#))
                                "& watches:"
                                (cljs.core/keys (.-watches res#))))]
       (freactive.core/add-invalidation-watch res# dbg-str# invalidation-cb#)
       res#)))

aaronc added a commit that referenced this pull request Nov 21, 2014
Changed `rx-debug` to `debug-rx` as it's actually called.
@aaronc aaronc merged commit 96e7410 into aaronc:master Nov 21, 2014
@aaronc
Copy link
Owner

aaronc commented Nov 21, 2014

Okay, so basically we would create an rx at the same time with this version. The only reason I wouldn't do this is because in the generic form, this macro could be used around anything that behaves like an rx. Actually right now, this macro can also provide info on when cursors are invalidated - might be useful too.

Thanks for the proofreading!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants