 [[:section {:title "Filtering and Sorting"}]]
 "Filtering and sorting work exactly as with `defview`."
 (fact defquery-filt
-      (defonce ps8 (ax/pubsub :name))
-      (defonce host8 {:pub (fn [ev])
-                      :sub (:sub ps8)
-                      :identity (atom "alice")
-                      :uuid (constantly "SOMEUUID")
-                      :time (constantly 12345)})
       (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)
-      (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"]))))
-
+      (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"])))))
+

                                 :data ["hello" 12345]
                                 :readers #{}
                                 :writers #{"alice"}}] 3)
      (let [valmap (first (my-tweets4 host4 "alice"))]
        (is (fn? (:swap! valmap)))
        ((:swap! valmap) assoc :tweet "world")
        (is (= @published4
               [{:kind :fact
                  :name "tweetlog/tweeted"
                  :key "alice"
                  :removed ["hello" 12345]
                  :data ["world" 12345]
                  :ts 34567
                  :change 3
                  :readers #{}
                  :writers #{"alice"}}]))))

[[:section {:title "Filtering"}]]
"Views can define client-side filtering for facts."

                                 :data ["hello"]
                                 :readers #{}
                                 :writers #{"alice"}}] 3)
      (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"}}]))))

"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)
