                                  :data ["hello"]
                                  :readers #{}
                                  :writers #{"alice"}}] 3)
-      (let [valmap (first (my-tweets3 host3 "alice"))]
+      (let [host {:pub #(swap! published3 conj %)
+                  :sub (fn [key f])
+                  :time (constantly 23456)}
+            valmap (first (my-tweets3 host "alice"))]
         (is (fn? (:del! valmap)))
         ((:del! valmap))
         (is (= @published3
                [{:kind :fact
-                  :name "tweetlog/tweeted"
-                  :key "alice"
-                  :data ["hello"]
-                  :ts 23456
-                  :change -3
-                  :readers #{}
-                  :writers #{"alice"}}]))))
+                 :name "tweetlog/tweeted"
+                 :key "alice"
+                 :data ["hello"]
+                 :ts 23456
+                 :change -3
+                 :readers #{}
+                 :writers #{"alice"}}]))))
 
 "A `:swap!` function provides a way to update a value map.
 It takes a function (and optionally arguments) that is applied to the value map, and emits an [atomic update](cloudlog-events.html#atomic-updates)

      (defonce my-atom4 (atom nil))
      (defonce published4 (atom nil))
      (reset! published4 nil)
      (defonce host4 {:pub #(swap! published4 conj %)
                      :sub (fn [key f])
                      :time (constantly 34567)})
      (defview my-tweets4 [user]
        [:tweetlog/tweeted user tweet ts]
        :store-in my-atom4)

[[:section {:title "Filtering and Sorting"}]]
"Filtering and sorting work exactly as with `defview`."
(fact defquery-filt
      (defonce my-atom8 (atom nil))
      (defquery tweets-by-authors-that-begin-in-b [user]
        [:tweetlog/timeline user -> author tweet]
        :store-in my-atom8
        :when (str/starts-with? author "b")
        :order-by tweet)
      (let [ps8 (ax/pubsub :name)
            host8 {:pub (fn [ev])
                   :sub (:sub ps8)
                   :identity (atom "alice")
                   :uuid (constantly "SOMEUUID")
                   :time (constantly 12345)}]
        (tweets-by-authors-that-begin-in-b host8 "alice") ;; Start listenning...
        ((:pub ps8)
         {:kind :fact
          :name "tweetlog/timeline!"
          :key "SOMEUUID"
          :data ["bob" "D"]
          :ts 1000
          :change 1
          :writers #{"XXYY"}
          :readers #{}})
        ((:pub ps8)
         {:kind :fact
          :name "tweetlog/timeline!"
          :key "SOMEUUID"
          :data ["charlie" "C"] ;; Dropped
          :ts 2000
          :change 1
          :writers #{"XXYY"}
          :readers #{}})
        ((:pub ps8)
         {:kind :fact
          :name "tweetlog/timeline!"
          :key "SOMEUUID"
          :data ["boaz" "B"]
          :ts 3000
          :change 1
          :writers #{"XXYY"}
          :readers #{}})
        ((:pub ps8)
         {:kind :fact
          :name "tweetlog/timeline!"
          :key "SOMEUUID"
          :data ["bob" "A"]
          :ts 4000
          :change 1
          :writers #{"XXYY"}
          :readers #{}})
        (let [results (tweets-by-authors-that-begin-in-b host8 "alice")]
          (is (= (count results) 3))
          (is (= (->> results
                      (map :tweet))
                 ["A" "B" "D"])))))

