diff options
author | Richard Macklin <richard.github@nrm.com> | 2019-01-14 11:35:04 -0800 |
---|---|---|
committer | Richard Macklin <richard.github@nrm.com> | 2019-01-14 11:35:04 -0800 |
commit | 6320916513891938f7d2f0b5c9c36968ee2d8705 (patch) | |
tree | 986965d8b9eb7cd3b0592dad07fd7b31e56a3ba2 /actioncable/app/javascript/action_cable/connection.js | |
parent | dbe073aebf198493a1a162d314c49dfcd5dbbf1b (diff) | |
download | rails-6320916513891938f7d2f0b5c9c36968ee2d8705.tar.gz rails-6320916513891938f7d2f0b5c9c36968ee2d8705.tar.bz2 rails-6320916513891938f7d2f0b5c9c36968ee2d8705.zip |
Simplify ActionCable.getConfig, Connection#getProtocol, and Connection#close
by relying on the implicit undefined return value
Diffstat (limited to 'actioncable/app/javascript/action_cable/connection.js')
-rw-r--r-- | actioncable/app/javascript/action_cable/connection.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/actioncable/app/javascript/action_cable/connection.js b/actioncable/app/javascript/action_cable/connection.js index b2910cb2a6..fddb920748 100644 --- a/actioncable/app/javascript/action_cable/connection.js +++ b/actioncable/app/javascript/action_cable/connection.js @@ -44,7 +44,9 @@ class Connection { close({allowReconnect} = {allowReconnect: true}) { if (!allowReconnect) { this.monitor.stop() } - if (this.isActive()) { return (this.webSocket ? this.webSocket.close() : undefined) } + if (this.isActive() && this.webSocket) { + return this.webSocket.close() + } } reopen() { @@ -65,7 +67,9 @@ class Connection { } getProtocol() { - return (this.webSocket ? this.webSocket.protocol : undefined) + if (this.webSocket) { + return this.webSocket.protocol + } } isOpen() { |