Guest User

Untitled

a guest
Mar 26th, 2014
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (let [start-xy-chan  (om/get-state owner :start-xy-chan)
  2.       change-xy-chan (om/get-state owner :change-xy-chan)
  3.       end-xy-chan    (om/get-state owner :end-xy-chan)]
  4.         (go
  5.           (loop []
  6.             (let [[x0 y0] (<! start-xy-chan)]
  7.               (loop []
  8.                 (let [[[x1 y1] ch] (alts! [change-xy-chan end-xy-chan])
  9.                       dx (- x0 x1)
  10.                       dy (- y0 y1)]
  11.                   (om/transact! app
  12.                     (fn [{:keys [currentUser] :as all}]
  13.                       (update-in all [:users currentUser :position]
  14.                         (let [zoom (get-in all [:users currentUser :zoom])]
  15.                           (fn [[x y]]
  16.                             [(+ x (/ dx zoom)) (+ y (/ dy zoom))]))))))
  17.                 (if (= ch change-xy-chan)
  18.                   (recur))))
  19.             (recur))))
Advertisement
Add Comment
Please, Sign In to add comment