Sha256: 51ddeb71d1238234347a5dd4f8b8c2dec132e26cb1424eae3260f51b66ee34a2
Contents?: true
Size: 803 Bytes
Versions: 51
Compression:
Stored size: 803 Bytes
Contents
import { createConsumer } from "@rails/actioncable"; import { debounce } from "throttle-debounce"; import { log } from "../plugins/logger"; 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( 200, (data) => { log.debug("Lookbook files changed"); callback(data); }, { atBegin: true } ), connected() { log.info("Lookbook websocket connected"); }, disconnected() { log.info("Lookbook websocket disconnected"); }, }); }, }; }
Version data entries
51 entries across 51 versions & 1 rubygems