Sha256: f098e3966010a0d3427822c98f7e039982170ad66ee056df5f9e7b34ea49ba1c

Contents?: true

Size: 692 Bytes

Versions: 32

Compression:

Stored size: 692 Bytes

Contents

import { createConsumer } from "@rails/actioncable";
import debounce from "debounce";

export default function socket(endpoint) {
  const uid = (Date.now() + ((Math.random() * 100) | 0)).toString();
  const consumer = createConsumer(`${endpoint}?uid=${uid}`);
  return {
    addListener(channel, callback) {
      consumer.subscriptions.create(channel, {
        received: debounce((data) => {
          console.log("Lookbook files changed");
          callback(data);
        }, 200),
        connected() {
          console.log("Lookbook websocket connected");
        },
        disconnected() {
          console.log("Lookbook websocket disconnected");
        },
      });
    },
  };
}

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
lookbook-0.9.8 app/assets/lookbook/js/lib/socket.js
lookbook-0.9.7 app/assets/lookbook/js/lib/socket.js
lookbook-0.9.6 app/assets/lookbook/js/lib/socket.js
lookbook-0.9.5 app/assets/lookbook/js/lib/socket.js
lookbook-0.9.4 app/assets/lookbook/js/lib/socket.js
lookbook-0.9.3 app/assets/lookbook/js/lib/socket.js
lookbook-0.9.2 app/assets/lookbook/js/lib/socket.js
lookbook-0.9.1 app/assets/lookbook/js/lib/socket.js
lookbook-0.9.0 app/assets/lookbook/js/lib/socket.js
lookbook-0.8.3 app/assets/lookbook/js/lib/socket.js
lookbook-0.8.2 app/assets/lookbook/js/lib/socket.js
lookbook-0.8.1 app/assets/lookbook/js/lib/socket.js
lookbook-0.8.0 app/assets/lookbook/js/lib/socket.js
lookbook-0.8.0.beta.0 app/assets/lookbook/js/lib/socket.js
lookbook-0.7.4 app/assets/lookbook/js/lib/socket.js
lookbook-0.7.3 app/assets/lookbook/js/lib/socket.js
lookbook-0.7.2 app/assets/lookbook/js/lib/socket.js
lookbook-0.7.2.beta.5 app/assets/lookbook/js/lib/socket.js
lookbook-0.7.2.beta.4 app/assets/lookbook/js/lib/socket.js
lookbook-0.7.2.beta.3 app/assets/lookbook/js/lib/socket.js