Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

prevent multiple subscriptions to same channel on same page #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/private_pub/view_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ def publish_to(channel, data = nil, &block)
def subscribe_to(channel)
subscription = PrivatePub.subscription(:channel => channel)
content_tag "script", :type => "text/javascript" do
raw("PrivatePub.sign(#{subscription.to_json});")
raw ("
if(PrivatePub.subscriptions['#{channel}'] === undefined){
PrivatePub.sign(#{subscription.to_json});
}
")
end
end
end
Expand Down