Sha256: aacf2ddb748b12053181f5ceab07e0d4db1f602a1997c661c4fda6c5970348d3

Contents?: true

Size: 583 Bytes

Versions: 2

Compression:

Stored size: 583 Bytes

Contents

# frozen_string_literal: true

module Loco
  module Emitter
    def emit(obj, event = nil, opts = {})
      Broadcaster.(
        obj,
        event,
        payload: opts[:payload] || opts[:data],
        recipients: opts[opts[:for] ? :for : :to]
      )
    end

    def emit_to(recipient_s, data)
      Sender.(recipient_s, data)
    end

    def add_hub(name, members = [])
      Hub.set(name, members)
    end

    def get_hub(name)
      Hub.get(name)
    end

    def del_hub(name)
      hub = Hub.get(name)
      return false if hub.nil?

      hub.destroy
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
loco-rails-6.0.0 lib/loco/emitter.rb
loco-rails-5.0.0 lib/loco/emitter.rb