Sha256: 280bc8f48f73fcc39a589dcb7247c97022890d61b0f730a753672339fd01ebd6

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module CableReady
  class Channel < OperationBuilder
    attr_reader :identifier

    def broadcast(clear: true)
      clients_received = ActionCable.server.broadcast identifier, {
        "cableReady" => true,
        "operations" => operations_payload,
        "version" => CableReady::VERSION
      }
      reset! if clear
      clients_received
    end

    def broadcast_to(model, clear: true)
      clients_received = identifier.broadcast_to model, {
        "cableReady" => true,
        "operations" => operations_payload,
        "version" => CableReady::VERSION
      }
      reset! if clear
      clients_received
    end

    def broadcast_later(clear: true)
      CableReadyBroadcastJob.perform_later(identifier: identifier, operations: operations_payload)
      reset! if clear
    end

    def broadcast_later_to(model, clear: true)
      CableReadyBroadcastJob.perform_later(identifier: identifier.name, operations: operations_payload, model: model)
      reset! if clear
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cable_ready-5.0.0.pre9 lib/cable_ready/channel.rb
cable_ready-5.0.0.pre8 lib/cable_ready/channel.rb