1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actioncable/app/javascript/action_cable/index.js
rmacklin d03177ffbc Simplify ActionCable.createWebSocketURL and realphabetize exports (#35810)
* Remove unnecessary variable from ActionCable.createWebSocketURL

* Improve ActionCable test by creating the Consumer before reassigning URL

With this change, the test now actually verifies that the Consumer's url
property changes dynamically (from testURL to `${testURL}foo`).

* Fix alphabetization of ActionCable exports
2019-04-02 23:04:43 +02:00

31 lines
783 B
JavaScript

import Connection from "./connection"
import ConnectionMonitor from "./connection_monitor"
import Consumer, { createWebSocketURL } from "./consumer"
import INTERNAL from "./internal"
import Subscription from "./subscription"
import Subscriptions from "./subscriptions"
import adapters from "./adapters"
import logger from "./logger"
export {
Connection,
ConnectionMonitor,
Consumer,
INTERNAL,
Subscription,
Subscriptions,
adapters,
createWebSocketURL,
logger,
}
export function createConsumer(url = getConfig("url") || INTERNAL.default_mount_path) {
return new Consumer(url)
}
export function getConfig(name) {
const element = document.head.querySelector(`meta[name='action-cable-${name}']`)
if (element) {
return element.getAttribute("content")
}
}