     (if (number? n)
       (concat (take-last n before) current (take n after))
       [])))
+
+(defn add-locations-before [app-db locations]
+  (update app-db :locations #(concat locations %)))
+
+(defn add-locations-after [app-db locations]
+  (update app-db :locations #(concat % locations)))
 
 (defn setup! []
   (re-frame/reg-sub

                               buffer-size
                               {:on-success #(re-frame/dispatch [:add-locations-after %])})
       true)))

  (re-frame/reg-sub
   :current-locations

  (let [current-locations (re-frame/subscribe [:current-locations])
        loading-before (re-frame/subscribe [:loading-before-buffer])
        loading-after  (re-frame/subscribe [:loading-after-buffer])]
    @loading-before
    @loading-after
    [reader #(re-frame/dispatch [:set-current-location %]) @current-locations]))
