From 0f761c0d51b8ccfd0d33562194cc5ef92199dc18 Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Wed, 24 Jun 2015 18:22:16 -0400 Subject: Update API to camel cased equivalent of WebSocket's API --- lib/assets/javascripts/channel.js.coffee | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'lib/assets/javascripts/channel.js.coffee') diff --git a/lib/assets/javascripts/channel.js.coffee b/lib/assets/javascripts/channel.js.coffee index 8bca24bd0e..5196d5e03f 100644 --- a/lib/assets/javascripts/channel.js.coffee +++ b/lib/assets/javascripts/channel.js.coffee @@ -2,21 +2,20 @@ class @Cable.Channel constructor: (@cable, params = {}, mixin) -> @identifier = JSON.stringify(params) extend(this, mixin) - - @cable.subscribe @identifier, - onConnect: => @connected?() - onDisconnect: => @disconnected?() - onReceiveData: (data) => @receive?(data) + @subscribe(@identifier, this) # Perform a channel action with the optional data passed as an attribute - perform: (action, data = {}) -> + sendAction: (action, data = {}) -> data.action = action - @cable.sendData(@identifier, JSON.stringify(data)) + @sendMessage(data) + + sendMessage: (data) -> + @cable.sendMessage(@identifier, JSON.stringify(data)) - send: (data) -> - @cable.sendData(@identifier, JSON.stringify(data)) + subscribe: -> + @cable.subscribe(@identifier, this) - close: -> + unsubscribe: -> @cable.unsubscribe(@identifier) extend = (object, properties) -> -- cgit v1.2.3