aboutsummaryrefslogtreecommitdiffstats
path: root/lib/assets/javascripts/channel.js.coffee
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2015-07-04 21:30:48 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2015-07-04 21:30:48 +0200
commit0de65cf2d8860377d45020a83866073c5fec188c (patch)
treed39b559162936fd79049595d69098fd7712a8fe3 /lib/assets/javascripts/channel.js.coffee
parent9886a995f5f0b32d0d400074c48221cb0f6b911e (diff)
parent5de01033150b70982f23a42670c55348a7371c4b (diff)
downloadrails-0de65cf2d8860377d45020a83866073c5fec188c.tar.gz
rails-0de65cf2d8860377d45020a83866073c5fec188c.tar.bz2
rails-0de65cf2d8860377d45020a83866073c5fec188c.zip
Merge branch 'master' of github.com:basecamp/action_cable
Diffstat (limited to 'lib/assets/javascripts/channel.js.coffee')
-rw-r--r--lib/assets/javascripts/channel.js.coffee34
1 files changed, 0 insertions, 34 deletions
diff --git a/lib/assets/javascripts/channel.js.coffee b/lib/assets/javascripts/channel.js.coffee
deleted file mode 100644
index 2f07affb19..0000000000
--- a/lib/assets/javascripts/channel.js.coffee
+++ /dev/null
@@ -1,34 +0,0 @@
-class @Cable.Channel
- constructor: (params = {}) ->
- @channelName ?= "#{@underscore(@constructor.name)}_channel"
-
- params['channel'] = @channelName
- @channelIdentifier = JSON.stringify params
-
- cable.subscribe(@channelIdentifier, {
- onConnect: @connected
- onDisconnect: @disconnected
- onReceiveData: @received
- })
-
-
- connected: =>
- # Override in the subclass
-
- disconnected: =>
- # Override in the subclass
-
- received: (data) =>
- # Override in the subclass
-
- # Perform a channel action with the optional data passed as an attribute
- perform: (action, data = {}) ->
- data.action = action
- cable.sendData @channelIdentifier, JSON.stringify data
-
- send: (data) ->
- cable.sendData @channelIdentifier, JSON.stringify data
-
-
- underscore: (value) ->
- value.replace(/[A-Z]/g, (match) => "_#{match.toLowerCase()}").substr(1) \ No newline at end of file