Sha256: 3e81290e5292a7ebb2715a243dd0b714ced1ffa791af7519e32e665fabdccea6

Contents?: true

Size: 965 Bytes

Versions: 3

Compression:

Stored size: 965 Bytes

Contents

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class ActionCableAdapter {
    constructor(actionCableClass) {
        this.connected = true;
        this.actionCableClass = actionCableClass;
        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 = this.actionCableClass.createConsumer();
        return this._cable.subscriptions.create({ channel: 'SyncChannel', key }, { received, disconnected, connected });
    }
    ondisconnect() { }
    onreconnect() { }
}
exports.default = ActionCableAdapter;

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ar_sync-1.0.4 core/ActionCableAdapter.js
ar_sync-1.0.3 core/ActioncableAdapter.js
ar_sync-1.0.2 core/ActioncableAdapter.js