 (def on-changes
   "An interceptor factory, which is to say, a function which will return an interceptor. 
    
-   The returned interceptor will observe N paths within `db`, and if any of them
+   Returns an interceptor which will observe N paths within `db`, and if any of them
    test not identical? to their previous value  (as a result of a event handler
    being run), then it runs `f` to compute a new value, which is then assoc-ed
    into the given `out-path` within `db`.
 
    Example Usage:
 
-   ```clj
+```clj
       (defn my-f
         [a-val b-val]
         ... some computation on a and b in here)
+   
+      ;; use it
+      (def my-interceptor (on-changes my-f [:c]  [:a] [:b]))
 
       (reg-event-db 
         :event-id 
-        [(on-changes my-f [:c]  [:a] [:b]) ... other interceptors]  <-- used here
+        [... my-interceptor ...]  ;; <-- ultimately used here
         (fn [db v]
            ...))
-    ```
-   
-    Put this Interceptor on the right handlers (ones which might change :a or :b)
+```
+   
+    Put this Interceptor on handlers which might change paths :a or :b
     and it will: 
    
      - call `f` each time the value at path [:a] or [:b] changes


;; -- dispatch ----------------------------------------------------------------
(defn dispatch
  "Enqueue `event` for processing by event handling machinery.

  `event` is a vector of length >= 1. The 1st element identifies the kind of event.

  Note: the event handler is not run immediately - it is not run
  synchronously. It will likely be run 'very soon', although it may be
  added to the end of a FIFO queue which already contain events.

  Usage:
     (dispatch [:order-pizza {:supreme 2 :meatlovers 1 :veg 1}])"
  [event]
  (router/dispatch event))

(defn dispatch-sync
  "Synchronously (immediately) process `event`. Do not queue.

  Generally, don't use this. Instead use `dispatch`. It is an error
  to use `dispatch-sync` within an event handler.

  Useful when any delay in processing is a problem:
     1. the `:on-change` handler of a text field where we are expecting fast typing.
     2  when initialising your app - see 'main' in todomvc examples
     3. in a unit test where we don't want the action 'later'

  Usage:
     (dispatch-sync [:sing :falsetto 634])"
  [event-v]
  (router/dispatch-sync event-v))




(defn console
  "A utility function for use in libraries which extend re-frame, like 
   perhaps an effect handler, when they want to produce log output.
   
   It will write the given `args` to js/console at the given `level`.
   
   `level` can be one of `:log` `:error` `:warn` `:debug` `:group` `:groupEnd`.
   
   Example usage: 
   

     (console :error \"Oh, dear God, it happened:\" a-var \"and\" another)
     (console :warn \"Possible breach of containment wall at:\" dt)

   "
  [level & args]
  (apply loggers/console (into [level] args)))
