Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Uncaught TypeError: Cannot read property 'autoReconnect' of null (and add deps.edn) #75

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{:deps {org.clojure/clojurescript {:mvn/version "1.10.520"}
org.clojure/clojure {:mvn/version "1.10.0"}
http-kit {:mvn/version "2.3.0"}}
:paths ["src/clj" "src/cljs"]}
2 changes: 1 addition & 1 deletion src/cljs/weasel/impls/websocket.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
([auto-reconnect?]
(websocket-connection auto-reconnect? nil))
([auto-reconnect? next-reconnect-fn]
(goog.net.WebSocket. auto-reconnect? next-reconnect-fn)))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great and obviously would work but have you also considered the following?

(goog.net.WebSocket. (js-obj "autoReconnect" auto-reconnect?) next-reconnect-fn)

(goog.net.WebSocket. (or auto-reconnect? false) (or next-reconnect-fn false))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to me those can be some let-bindings instead, as the code looks a bit weird as proposed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, and false doesn't seem to be valid according to https://google.github.io/closure-library/api/goog.net.WebSocket.Options.html

maybe

(goog.net.WebSocket. (clj->js
                      (cond-> {}
                        auto-reconnect?   (assoc "autoReconnect" auto-reconnect?)
                        next-reconnect-fn (assoc "getNextReconnect" next-reconnect-fn))))

or, to make things clearer, using something like assoc-some from https://github.com/weavejester/medley/blob/1.3.0/src/medley/core.cljc#L38


(extend-type goog.net.WebSocket
IWebSocket
Expand Down