mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
23 lines
533 B
JavaScript
23 lines
533 B
JavaScript
import { Controller } from "stimulus";
|
|
import consumer from "../channels/consumer";
|
|
import CableReady from "cable_ready";
|
|
|
|
export default class extends Controller {
|
|
static values = { id: String };
|
|
|
|
connect() {
|
|
this.subscription = consumer.subscriptions.create(
|
|
{ channel: "ScopedChannel", id: this.idValue },
|
|
{
|
|
received(data) {
|
|
if (data.cableReady) CableReady.perform(data.operations);
|
|
},
|
|
},
|
|
);
|
|
}
|
|
|
|
disconnect() {
|
|
consumer.subscriptions.remove(this.subscription);
|
|
}
|
|
}
|