diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2015-12-15 21:38:58 +0100 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2015-12-15 21:39:22 +0100 |
commit | 40cc72548f529fbe3a52577dca3d0517f631f1b5 (patch) | |
tree | 2828aed91c7c04df439089ad309df6f8dc394ba1 /actioncable/lib/rails/generators/channel/templates/assets | |
parent | 649b9d93219b5b38bb2fccba5124c4e013726d9e (diff) | |
download | rails-40cc72548f529fbe3a52577dca3d0517f631f1b5.tar.gz rails-40cc72548f529fbe3a52577dca3d0517f631f1b5.tar.bz2 rails-40cc72548f529fbe3a52577dca3d0517f631f1b5.zip |
Basic channel generator
Diffstat (limited to 'actioncable/lib/rails/generators/channel/templates/assets')
-rw-r--r-- | actioncable/lib/rails/generators/channel/templates/assets/channel.coffee | 11 | ||||
-rw-r--r-- | actioncable/lib/rails/generators/channel/templates/assets/consumer.coffee | 6 |
2 files changed, 17 insertions, 0 deletions
diff --git a/actioncable/lib/rails/generators/channel/templates/assets/channel.coffee b/actioncable/lib/rails/generators/channel/templates/assets/channel.coffee new file mode 100644 index 0000000000..69f945ca3f --- /dev/null +++ b/actioncable/lib/rails/generators/channel/templates/assets/channel.coffee @@ -0,0 +1,11 @@ +App.<%= class_name.underscore %> = App.cable.subscriptions.create "<%= class_name %>Channel", + connected: -> + # Called when the subscription is ready for use on the server + + disconnected: -> + # Called when the subscription has been terminated by the server + +<% actions.each do |action| -%> + <%= action %>: -> + @perform '<%= action %>' +<% end -%> diff --git a/actioncable/lib/rails/generators/channel/templates/assets/consumer.coffee b/actioncable/lib/rails/generators/channel/templates/assets/consumer.coffee new file mode 100644 index 0000000000..5bb6ab8296 --- /dev/null +++ b/actioncable/lib/rails/generators/channel/templates/assets/consumer.coffee @@ -0,0 +1,6 @@ +#= require cable +#= require_self +#= require ./channels + +@App = {} +App.cable = Cable.createConsumer() |