要创建订阅,我运行:
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
});
}
});
但是因为我希望客户永远不会订阅多个频道,所以在此之前我每次可以运行什么来删除客户拥有的所有订阅?
我试图做一些超级hacky的事情,比如:
App.cable.subscriptions['subscriptions'] = [App.cable.subscriptions['subscriptions'][1, 0]]
但我确信它不起作用,因为订阅/取消订阅还有许多其他组件。
App.cable.subscriptions.remove 需要一个订阅参数,但我要传入什么?
谢谢!