From 6be2604aa719713c602b8a873337d328196f8f57 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Sun, 15 Nov 2015 21:09:14 +0100 Subject: 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. --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5c6cb1c0fe..4a7c3ca707 100644 --- a/README.md +++ b/README.md @@ -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. -- cgit v1.2.3