Use different events for full sync, full sync request
This commit is contained in:
parent
0f06d21767
commit
52ce9ffb42
3 changed files with 11 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
|||
(ns grub.message)
|
||||
|
||||
(def full-sync-request {:type :full-sync})
|
||||
(def full-sync-request {:type :full-sync-request})
|
||||
|
||||
(defn full-sync [state]
|
||||
{:type :full-sync
|
||||
|
|
|
@ -35,16 +35,17 @@
|
|||
(let [state (sync/get-current-state states*)]
|
||||
(>! out (message/full-sync state))
|
||||
(recur state)))))
|
||||
|
||||
:full-sync-request
|
||||
(let [state (sync/get-current-state @states)]
|
||||
(>! out (message/full-sync state))
|
||||
(recur state))
|
||||
|
||||
:full-sync
|
||||
(if client?
|
||||
(let [state (:state msg)]
|
||||
(reset! states (sync/new-state state))
|
||||
(recur state))
|
||||
(let [state (sync/get-current-state @states)]
|
||||
(>! out (message/full-sync state)) ;; HERE
|
||||
(recur state)))
|
||||
|
||||
(let [state (:state msg)]
|
||||
(reset! states (sync/new-state state))
|
||||
(recur state))
|
||||
|
||||
:new-state
|
||||
(let [{:keys [diff hash]} (sync/diff-states (:state msg) shadow)]
|
||||
(when-not (sync/empty-diff? diff)
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
{:grubs {"1" {:text "2 apples" :completed false}
|
||||
"2" {:text "3 onions" :completed false}}
|
||||
:recipes {}})
|
||||
msg {:type :full-sync}
|
||||
msg {:type :full-sync-request}
|
||||
in (chan 1)
|
||||
out (chan 1)]
|
||||
(state/make-server-agent in out states)
|
||||
|
|
Loading…
Reference in a new issue