Created
January 10, 2021 22:41
-
-
Save cindywu/236e1619d7cb5ab07b61f0d28811ec70 to your computer and use it in GitHub Desktop.
chapter 5 create the web socket
This file contains hidden or 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 connect! [url receive-handler] | |
(if-let [chan (js/WebSocket. url)] | |
(do | |
(set! (.-onmessage chan) (receive-message! receive-handler)) | |
(reset! ws-chan chan)) | |
(throw (js/Error. "WebSocket connection failed!")))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment