mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
6d7c12274e
A SubscriptionGuarantor maintains a set of pending subscriptions, resending the subscribe command unless and until the subscription is confirmed or rejected by the server or cancelled client-side. A race condition in the ActionCable server - where an unsubscribe is sent, followed rapidly by a subscribe, but handled in the reverse order - necessitates this enhancement. Indeed, the subscriptions created and torn down by Turbo Streams amplifies the existence of this race condition.
33 lines
869 B
JavaScript
33 lines
869 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 SubscriptionGuarantor from "./subscription_guarantor"
|
|
import adapters from "./adapters"
|
|
import logger from "./logger"
|
|
|
|
export {
|
|
Connection,
|
|
ConnectionMonitor,
|
|
Consumer,
|
|
INTERNAL,
|
|
Subscription,
|
|
Subscriptions,
|
|
SubscriptionGuarantor,
|
|
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")
|
|
}
|
|
}
|