 
 (enable-console-print!)
 
+;; helper function to print to js/console
+(defn console-log [msg & more-msgs]
+  (.log js/console (str msg more-msgs)))
+
 ;; setting reddit-api properties for dev or prod
 (if (= "pvik.github.io" (get (clojure.string/split (str (.-location js/window)) #"/") 2))
   (do

(def saved-posts (r/atom {}))
(def subreddits (r/atom {}))
(def get-posts? (r/atom true))

(defn clear-and-refresh-app []
  (alandipert.storage-atom/remove-local-storage! :saved-for-reddit-app-state)


(defn reddit-get-username [token callback]
  ;; request username
  (console-log "in get-username")
  (go (let [response (<! (http/get "https://oauth.reddit.com/api/v1/me"
                                   {:with-credentials? false
                                    :oauth-token token}))
            body  (:body response)
            error (:error body)]
        (console-log body)
        (if (or (nil? error) (clojure.string/blank? error))
          (let [username (:name body)]
            (set-app-state-field :username username))
