Class: ModelsChannel

Inherits:
ActionCable::Channel::Base
  • Object
show all
Defined in:
app/channels/models_channel.rb

Overview

Rails currently doesn’t allow namespacing channels in an engine module ActiveSync

Instance Method Summary collapse

Instance Method Details

#subscribedObject

To change the data sent implement sync_record in the respective model



6
7
8
9
10
11
12
13
# File 'app/channels/models_channel.rb', line 6

def subscribed
  transmit(subscription_model.where(params[:filter]).map(&:sync_record))
  stream_from params[:model], coder: ActiveSupport::JSON do |message|
    if (params[:filter].to_a - message.to_a).blank?
      transmit([message])
    end
  end
end

#unsubscribedObject



15
16
17
# File 'app/channels/models_channel.rb', line 15

def unsubscribed
  # Any cleanup needed when channel is unsubscribed
end