From fa0281aeb122058fa7d353fcd74e08a6702a9061 Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Thu, 25 Jun 2015 16:12:26 -0400 Subject: Cable.Channel -> Cable.Subscription --- lib/assets/javascripts/cable.js.coffee | 6 +++--- lib/assets/javascripts/cable/channel.js.coffee | 22 ---------------------- .../javascripts/cable/subscription.js.coffee | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 25 deletions(-) delete mode 100644 lib/assets/javascripts/cable/channel.js.coffee create mode 100644 lib/assets/javascripts/cable/subscription.js.coffee diff --git a/lib/assets/javascripts/cable.js.coffee b/lib/assets/javascripts/cable.js.coffee index 0f1d7c8773..fad5aa05d3 100644 --- a/lib/assets/javascripts/cable.js.coffee +++ b/lib/assets/javascripts/cable.js.coffee @@ -1,7 +1,7 @@ #= require_self #= require cable/subscriber_manager #= require cable/connection -#= require cable/channel +#= require cable/subscription class @Cable @PING_IDENTIFIER: "_ping" @@ -10,10 +10,10 @@ class @Cable @subscribers = new Cable.SubscriberManager this @connection = new Cable.Connection this - createChannel: (channelName, mixin) -> + createSubscription: (channelName, mixin) -> channel = channelName params = if typeof channel is "object" then channel else {channel} - new Cable.Channel this, params, mixin + new Cable.Subscription this, params, mixin send: (data) -> @connection.send(data) diff --git a/lib/assets/javascripts/cable/channel.js.coffee b/lib/assets/javascripts/cable/channel.js.coffee deleted file mode 100644 index 9168a76d3c..0000000000 --- a/lib/assets/javascripts/cable/channel.js.coffee +++ /dev/null @@ -1,22 +0,0 @@ -class Cable.Channel - constructor: (@cable, params = {}, mixin) -> - @identifier = JSON.stringify(params) - extend(this, mixin) - @cable.subscribers.add(this) - - # Perform a channel action with the optional data passed as an attribute - perform: (action, data = {}) -> - data.action = action - @send(data) - - send: (data) -> - @cable.send(command: "message", identifier: @identifier, data: JSON.stringify(data)) - - unsubscribe: -> - @cable.subscribers.remove(this) - - extend = (object, properties) -> - if properties? - for key, value of properties - object[key] = value - object diff --git a/lib/assets/javascripts/cable/subscription.js.coffee b/lib/assets/javascripts/cable/subscription.js.coffee new file mode 100644 index 0000000000..8057ff7790 --- /dev/null +++ b/lib/assets/javascripts/cable/subscription.js.coffee @@ -0,0 +1,22 @@ +class Cable.Subscription + constructor: (@cable, params = {}, mixin) -> + @identifier = JSON.stringify(params) + extend(this, mixin) + @cable.subscribers.add(this) + + # Perform a channel action with the optional data passed as an attribute + perform: (action, data = {}) -> + data.action = action + @send(data) + + send: (data) -> + @cable.send(command: "message", identifier: @identifier, data: JSON.stringify(data)) + + unsubscribe: -> + @cable.subscribers.remove(this) + + extend = (object, properties) -> + if properties? + for key, value of properties + object[key] = value + object -- cgit v1.2.3