        [:footer#info
         [:p "Double-click to edit a todo"]]])))
 
-(defn ^:export run
+(defn main-panel
+  []
+  (let [initialised? (subscribe  [:initialised?])]
+    (fn []
+      (if @initialised?
+        [todo-app]
+        [:div "Loading ...."]))))
+
+(defn ^:export main
   []
   (dispatch [:initialise-db])
-  (reagent/render [todo-app] (js/document.getElementById "app")))
+  (reagent/render [main-panel] (js/document.getElementById "app")))
+
+                 ;; you must always return the db
;; change example.html to todo.html
;; add middleware to save to local storage - beware using
;; check that (path )  does an identity test before swaping back in
;; add apply-vector middleware

;; -- Helpers -------------

(defn next-id
  [todos]
  (if (empty? todos)
    0
    (inc (apply max (keys todos)))))  ;; hillariously inefficient, but yeah


;; -- Middleware -------------
;;

                                   register-sub
                                   subscribe
                                   dispatch
                                   path trim-v debug]]))

;; TODOs
;; add .gitignore
