diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2015-11-15 21:09:14 +0100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2015-11-15 21:09:14 +0100 |
commit | 6be2604aa719713c602b8a873337d328196f8f57 (patch) | |
tree | 23a04570de043456c9aca21420d292a343d1b83c /README.md | |
parent | 63cdbf87ddaeb6bbc852de7ca2c504b7f6a22321 (diff) | |
download | rails-6be2604aa719713c602b8a873337d328196f8f57.tar.gz rails-6be2604aa719713c602b8a873337d328196f8f57.tar.bz2 rails-6be2604aa719713c602b8a873337d328196f8f57.zip |
Tune whitespace in README.md
* Realign `end` statements with the opening `class` statement.
* Pad JavaScript objects with spaces to match Rails styleguide and for consistency with other examples.
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -187,7 +187,7 @@ class WebNotificationsChannel < ApplicationCable::Channel def subscribed stream_from "web_notifications_#{current_user.id}" end - end +end ``` ```coffeescript @@ -219,14 +219,14 @@ class ChatChannel < ApplicationCable::Channel def subscribed stream_from "chat_#{params[:room]}" end - end +end ``` Pass an object as the first argument to `subscriptions.create`, and that object will become your params hash in your cable channel. The keyword `channel` is required. ```coffeescript # Client-side which assumes you've already requested the right to send web notifications -App.cable.subscriptions.create {channel: "ChatChannel", room: "Best Room"}, +App.cable.subscriptions.create { channel: "ChatChannel", room: "Best Room" }, received: (data) -> new Message data['sent_by'], body: data['body'] ``` @@ -257,11 +257,11 @@ end ```coffeescript # Client-side which assumes you've already requested the right to send web notifications -sub = App.cable.subscriptions.create {channel: "ChatChannel", room: "Best Room"}, +sub = App.cable.subscriptions.create { channel: "ChatChannel", room: "Best Room" }, received: (data) -> new Message data['sent_by'], body: data['body'] -sub.send {sent_by: 'Peter', body: 'Hello Paul, thanks for the compliment.'} +sub.send { sent_by: 'Peter', body: 'Hello Paul, thanks for the compliment.' } ``` The rebroadcast will be received by all connected clients, _including_ the client that sent the message. Note that params are the same as they were when you subscribed to the channel. |