Class: Interfacets::Test::Js::InlineBus

Inherits:
Object
  • Object
show all
Defined in:
lib/interfacets/test/js/inline_bus.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(receiver_index:, client_system_json:) ⇒ InlineBus

Returns a new instance of InlineBus.



8
9
10
11
# File 'lib/interfacets/test/js/inline_bus.rb', line 8

def initialize(receiver_index:, client_system_json:)
  @receiver_index = receiver_index
  @client_system_json = client_system_json
end

Instance Attribute Details

#client_system_json ⇒ Object (readonly)

Returns the value of attribute client_system_json.



7
8
9
# File 'lib/interfacets/test/js/inline_bus.rb', line 7

def client_system_json
  @client_system_json
end

#receiver_index ⇒ Object (readonly)

Returns the value of attribute receiver_index.



7
8
9
# File 'lib/interfacets/test/js/inline_bus.rb', line 7

def receiver_index
  @receiver_index
end

Instance Method Details

#dispatch(channel_id, event) ⇒ Object



33
34
35
# File 'lib/interfacets/test/js/inline_bus.rb', line 33

def dispatch(channel_id, event)
  dispatch_to_bus(bus_id: "default", channel_id: channel_id, event: event)
end

#handler(channel_id) ⇒ Object



13
14
15
# File 'lib/interfacets/test/js/inline_bus.rb', line 13

def handler(channel_id)
  receiver_index.fetch(channel_id).handler
end

#init(hydrated_facet:) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/interfacets/test/js/inline_bus.rb', line 17

def init(hydrated_facet:)
  client.handle(H.j({
    type: "interfacets:system:create_bus",
    payload: {
      id: "default",
      channel_ids: ["interfacets:api", "dom", "url", "timer"],
      hydration: {
        destination: { bus: "default", channel: "interfacets:api" },
        type: "interfacets:api:hydrate",
        payload: hydrated_facet
      },
      config: client_system_json,
    }
  }))
end