Sha256: d76f1e80c4054e1113d606e7967d138ffa8e270963ac308fe4dae52da0e83a2d

Contents?: true

Size: 672 Bytes

Versions: 9

Compression:

Stored size: 672 Bytes

Contents

import { createConsumer } from 'https://esm.sh/@rails/actioncable@6.0.5'
import debounce from 'https://esm.sh/debounce@1.2.1'

export default socketPath => {
  const uid = (Date.now() + ((Math.random() * 100) | 0)).toString()
  const consumer = createConsumer(`${socketPath}?uid=${uid}`)

  consumer.subscriptions.create('Proscenium::ReloadChannel', {
    received: debounce(() => {
      console.log('Proscenium files changed; reloading...')
      location.reload()
    }, 200),

    connected() {
      console.log('Proscenium auto reload websocket connected')
    },

    disconnected() {
      console.log('Proscenium auto reload websocket disconnected')
    }
  })
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
proscenium-0.1.0.alpha3-arm64-darwin lib/proscenium/runtime/auto_reload.js
proscenium-0.1.0.alpha3-x86_64-darwin lib/proscenium/runtime/auto_reload.js
proscenium-0.1.0.alpha3-x86_64-linux lib/proscenium/runtime/auto_reload.js
proscenium-0.1.0.alpha2-x86_64-linux lib/proscenium/runtime/auto_reload.js
proscenium-0.1.0.alpha2-x86_64-darwin lib/proscenium/runtime/auto_reload.js
proscenium-0.1.0.alpha2-arm64-darwin lib/proscenium/runtime/auto_reload.js
proscenium-0.1.0.alpha1-x86_64-linux lib/proscenium/runtime/auto_reload.js
proscenium-0.1.0.alpha1-x86_64-darwin lib/proscenium/runtime/auto_reload.js
proscenium-0.1.0.alpha1-arm64-darwin lib/proscenium/runtime/auto_reload.js