Created
November 6, 2014 08:46
-
-
Save blissdev/a9d58df627eb2877cb30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn subscribe-to-match [owner match-id] | |
(let [pusher (om/get-shared owner :pusher) | |
previous-channel (om/get-state owner :match-pusher-chan) | |
new-channel (.subscribe pusher (str "match-" match-id)) | |
events-chan (om/get-shared owner :match-events-chan) | |
events-list ["draft_character" "begin" "update_score" | |
"set_turn_number" "add_target" "remove_target" | |
"change_round" "change_turn" "update_health"]] | |
(when previous-channel (.unbind previous-channel)) | |
(doseq [event-name events-list] | |
(.bind new-channel event-name #(match-event % events-chan event-name))) | |
(om/set-state! owner :match-pusher-chan new-channel))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment