Simplify ActionCable.createConsumer by using default argument

This commit is contained in:
Richard Macklin 2019-01-14 11:32:56 -08:00
parent 3631d7eee4
commit dbe073aebf
2 changed files with 3 additions and 10 deletions

View File

@ -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) {

View File

@ -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))
}