Created
August 21, 2014 13:07
-
-
Save robert-stuttaford/ec613ab70c3aa77f8c46 to your computer and use it in GitHub Desktop.
Nicely grouped transaction logging in JS Console for Om apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns app | |
(:require [om.core :as om :include-macros true])) | |
(defn log-tx [tx-data root-cursor] | |
(let [{:keys [path old-value new-value]} tx-data | |
c js/console] | |
(doto c (.group (str "TRANSACTION " path)) (.groupCollapsed "OLD")) | |
(prn (pr-str old-value)) | |
(doto c (.groupEnd) (.group "NEW")) | |
(prn (pr-str new-value)) | |
(doto c (.groupEnd) (.groupEnd)))) | |
(defn render | |
[root state app debug?] | |
(when debug? | |
(enable-console-print!)) | |
(om/root app | |
state | |
(cond-> {:target root | |
:shared {:config (assoc (:config state) :debug? debug?)}} | |
debug? (assoc :tx-listen log-tx)))) | |
;; (render (.getElementById "app") {:config {...} ...} app-component :debug) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment