      :clj  (instance? clojure.lang.IAtom a)))
 
 (defn listen!
+  "Listen for changes on the given database connection.
+  Whenever a transaction is applied to the database the callback is called
+  with the transaction report.
+  Returns the key under which this listener is registered."
   ([conn callback] (listen! conn (rand) callback))
   ([conn key callback]
      {:pre [(conn? conn) (atom? (:listeners (meta conn)))]}
      (swap! (:listeners (meta conn)) assoc key callback)
      key))
 
-(defn unlisten! [conn key]
+(defn unlisten!
+  "Removes the listener under de given key from the database connection."
+  [conn key]
   {:pre [(conn? conn) (atom? (:listeners (meta conn)))]}
   (swap! (:listeners (meta conn)) dissoc key))
 

;;  (clojure.edn/read-string {:readers datascript/data-readers} "...")
;;

(def data-readers {'datascript/Datom db/datom-from-reader
                   'datascript/DB    db/db-from-reader})

#?(:cljs
   (doseq [[tag cb] data-readers] (cljs.reader/register-tag-parser! tag cb)))

(defn resolve-tempid [_db tempids tempid]
  (get tempids tempid))

(defn db
  "Extracts the current database (as a value) from the connection."
  [conn]
  {:pre [(conn? conn)]}
  @conn)

