Sha256: b9a6be414c128dcc9b43ac7cdc433cbfdcef3324b947bfcda0457e03db2e24f7

Contents?: true

Size: 420 Bytes

Versions: 10

Compression:

Stored size: 420 Bytes

Contents

let consumer

export async function getConsumer() {
  if (consumer) return consumer
  const { createConsumer } = await import("@rails/actioncable/src")
  return setConsumer(createConsumer())
}

export function setConsumer(newConsumer) {
  return consumer = newConsumer
}

export async function subscribeTo(channel, mixin) {
  const { subscriptions } = await getConsumer()
  return subscriptions.create(channel, mixin)
}

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
turbo-rails-0.5.9 app/javascript/turbo/cable.js
turbo-rails-0.5.8 app/javascript/turbo/cable.js
turbo-rails-0.5.7 app/javascript/turbo/cable.js
turbo-rails-0.5.6 app/javascript/turbo/cable.js
turbo-rails-0.5.5 app/javascript/turbo/cable.js
turbo-rails-0.5.4 app/javascript/turbo/cable.js
turbo-rails-0.5.3 app/javascript/turbo/cable.js
turbo-rails-0.5.2 app/javascript/turbo/cable.js
turbo-rails-0.5.1 app/javascript/turbo/cable.js
turbo-rails-0.5.0 app/javascript/turbo/cable.js