   (swap! state add-listener event f))
 
 (def twitter-uri (goog.Uri. "http://twitter.com/search.json"))
+
+(defn search-tag
+  "Get the current tag value from the page."
+  []
+  (.value (dom/getElement "twitter-search-tag")))
 
 (defn retrieve [payload callback]
   (.send (goog.net.Jsonp. twitter-uri)

         (send-event :new-tweets tweets)
         (send-event :graph-update (:graph @state)))))

(defn search-tag
  "Get the current tag value from the page."
  []
  (.value (dom/getElement "twitter-search-tag")))

(defn do-timer []
  (let [tag (search-tag)]
    (when (not (empty? tag))
      (retrieve (.strobj {"q" tag "rpp" 100}) my-callback))))

(defn poll
  "Request new data from twitter once every 24 seconds. This will put

        (events/listen timer goog.Timer/TICK do-timer))))

(defn do-track-button-clicked []
  (do (let [listeners (:listeners @state)]
        (reset! state (assoc initial-state :listeners listeners :search-tag (search-tag))))
      (do-timer)
      (send-event :track-clicked)))

(defn do-refresh-button-clicked []
  (send-event :refresh-clicked))

(defn start-app []
  (do (poll)
      (events/listen (dom/getElement "twitter-search-button")
                     "click"
                     do-track-button-clicked)
      (events/listen (dom/getElement "refresh-button")
                     "click"
                     do-refresh-button-clicked)))

(start-app)

(comment

