Class: Turbo::StreamsChannel

Inherits:
ActionCable::Channel::Base
  • Object
show all
Extended by:
Turbo::Streams::Broadcasts, Turbo::Streams::StreamName
Defined in:
app/channels/turbo/streams_channel.rb

Overview

The streams channel delivers all the turbo-stream actions created (primarily) through Turbo::Broadcastable. A subscription to this channel is made for each individual stream that one wishes to listen for updates to. The subscription relies on being passed a signed_stream_name parameter generated by turning a set of streamables into signed stream name using Turbo::Streams::StreamName#signed_stream_name. This is automatically done using the view helper Turbo::StreamsHelper#turbo_stream_from(*streamables). If the signed stream name cannot be verified, the subscription is rejected.

Instance Method Summary collapse

Instance Method Details

#subscribedObject



10
11
12
13
14
15
16
# File 'app/channels/turbo/streams_channel.rb', line 10

def subscribed
  if verified_stream_name = self.class.verified_stream_name(params[:signed_stream_name])
    stream_from verified_stream_name
  else
    reject
  end
end