Sha256: c43b9143272c0be6116148f1c4ed1339fe1e6e2c01b0bfc8aa71071b5c1a1082

Contents?: true

Size: 933 Bytes

Versions: 2

Compression:

Stored size: 933 Bytes

Contents

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ActionCable = require("actioncable");
class ActionCableAdapter {
    constructor() {
        this.connected = true;
        this.subscribe(Math.random().toString(), () => { });
    }
    subscribe(key, received) {
        const disconnected = () => {
            if (!this.connected)
                return;
            this.connected = false;
            this.ondisconnect();
        };
        const connected = () => {
            if (this.connected)
                return;
            this.connected = true;
            this.onreconnect();
        };
        if (!this._cable)
            this._cable = ActionCable.createConsumer();
        return this._cable.subscriptions.create({ channel: 'SyncChannel', key }, { received, disconnected, connected });
    }
    ondisconnect() { }
    onreconnect() { }
}
exports.default = ActionCableAdapter;

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ar_sync-1.0.1 core/ActioncableAdapter.js
ar_sync-1.0.0 core/ActioncableAdapter.js