diff options
author | Richard Macklin <richard.github@nrm.com> | 2019-01-14 11:32:56 -0800 |
---|---|---|
committer | Richard Macklin <richard.github@nrm.com> | 2019-01-14 11:33:24 -0800 |
commit | dbe073aebf198493a1a162d314c49dfcd5dbbf1b (patch) | |
tree | 82082bf8238dce790466a9e3ae3feb58e8bf22fe /actioncable/app | |
parent | 3631d7eee4bd034f2eefe1b9892d5fcd565579ac (diff) | |
download | rails-dbe073aebf198493a1a162d314c49dfcd5dbbf1b.tar.gz rails-dbe073aebf198493a1a162d314c49dfcd5dbbf1b.tar.bz2 rails-dbe073aebf198493a1a162d314c49dfcd5dbbf1b.zip |
Simplify ActionCable.createConsumer by using default argument
Diffstat (limited to 'actioncable/app')
-rw-r--r-- | actioncable/app/assets/javascripts/action_cable.js | 7 | ||||
-rw-r--r-- | actioncable/app/javascript/action_cable/index.js | 6 |
2 files changed, 3 insertions, 10 deletions
diff --git a/actioncable/app/assets/javascripts/action_cable.js b/actioncable/app/assets/javascripts/action_cable.js index 65e32d6c3f..7710313c40 100644 --- a/actioncable/app/assets/javascripts/action_cable.js +++ b/actioncable/app/assets/javascripts/action_cable.js @@ -452,11 +452,8 @@ }; return Consumer; }(); - function createConsumer(url) { - if (url == null) { - var urlConfig = getConfig("url"); - url = urlConfig ? urlConfig : INTERNAL.default_mount_path; - } + function createConsumer() { + var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getConfig("url") || INTERNAL.default_mount_path; return new Consumer(createWebSocketURL(url)); } function getConfig(name) { diff --git a/actioncable/app/javascript/action_cable/index.js b/actioncable/app/javascript/action_cable/index.js index 9f41c14e94..ddcd4dcebc 100644 --- a/actioncable/app/javascript/action_cable/index.js +++ b/actioncable/app/javascript/action_cable/index.js @@ -18,11 +18,7 @@ export { logger, } -export function createConsumer(url) { - if (url == null) { - const urlConfig = getConfig("url") - url = (urlConfig ? urlConfig : INTERNAL.default_mount_path) - } +export function createConsumer(url = getConfig("url") || INTERNAL.default_mount_path) { return new Consumer(createWebSocketURL(url)) } |