To create subscriptions I run:
App.room = App.cable.subscriptions.create({
channel: "RoomChannel",
roomId: roomId
}, {
connected: function() {},
disconnected: function() {},
received: function(data) {
return $('#messages').append(data['message']);
},
speak: function(message, roomId) {
return this.perform('speak', {
message: message,
roomId: roomId
});
}
});
But because I want the client to never be subscribed to more than one channel, what can I run each time before this to remove all subscriptions the client has?
I tried to do something super hacky like:
App.cable.subscriptions['subscriptions'] = [App.cable.subscriptions['subscriptions'][1, 0]]
But I'm sure it didn't work because there are many other components that go into a subscription/unsubscription.
App.cable.subscriptions.remove requires a subscription argument, but what do I pass in?
Thanks!