Advertisement
dredder_gun

coeffect_re_frame

Jul 13th, 2017
676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (re-frame/reg-cofx
  2.   :local-store-todos
  3.   (let [todos-output (r/atom (sorted-map))
  4.         counter (r/atom 0)]
  5.     (fn [cofx _]
  6.         (GET GET_ALL_URL
  7.           { :format :json
  8.             :response-format :json
  9.             :keywords? true
  10.             :timeout 5000
  11.             :handler
  12.               (fn [resp]
  13.                 (when-let [todo-clauses (:ok resp)]
  14.                   (reset!
  15.                     todos-output
  16.                     (map #(do
  17.                             (swap! counter inc)
  18.                             (swap! todos-output into @counter {:id @counter :db_id (:id %) :title (:text %) :done (:done %)})) todo-clauses))))
  19.             ;
  20.             :error-handler
  21.               (fn [err]
  22.                 (.error js/console "do-login:" (clj->js err)))})
  23.             ;
  24.             @todos-output)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement